Created
July 15, 2022 16:26
-
-
Save Octagon-simon/30c310329d11af857487fb5829d0d415 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //store required extensions | |
| const requiredExts = [".png", ".jpg", ".jpeg"]; | |
| //store error | |
| const valError = []; | |
| //loop through object | |
| for (let file of fileInpFiles){ | |
| //retrieve extension from name | |
| const ext = file.name.substring(file.name.lastIndexOf('.')); | |
| //check if it matches with the required extension | |
| if ( !requiredExts.includes( ext ) ){ | |
| //store file name that doesn't match the extension | |
| valError.push( file.name ); | |
| } | |
| } | |
| //check if there's a validation error | |
| if( valError.length !== 0 ){ | |
| valError.forEach( f => { | |
| console.log(`${f} is not supported`); | |
| } ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment