Advertisement
jackluciano

Untitled

Mar 12th, 2024
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. function filterFiles(files: string[], suffix: string): string[] {
  2. return files.filter(file => {
  3. const fileName = file.toLowerCase();
  4. return (fileName.includes(suffix) || fileName.includes('_v3')) &&
  5. (fileName.endsWith(suffix) || fileName.endsWith('_v3'));
  6. });
  7. }
  8.  
  9. // Változó értéke
  10. const suffix = "sa";
  11.  
  12. // Teszteset:
  13. const files = ["weapons.txt", "weapons_sa.txt", "weapons_v3.txt", "something_v3_else_sa.txt", "file_v4.txt"];
  14. const filteredFiles = filterFiles(files, suffix);
  15. console.log(filteredFiles);
  16.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement