JSFiddle - React, Tailwind, and code Playground

by Sunny SM

JavaScript

const filesTypes = [
  'doc',
  'docx',
  'odt',
  'pdf',
  'xls',
  'xlsx',
  'ods',
  'ppt',
  'pptx',
  'txt',
  'jpeg',
  'jpg',
  'png',
  'tiff',
  'gif',
  'bmp'
];

const allowedFileFormat = item => (item.slice((item.lastIndexOf(".") - 1 >>> 0) + 2)).toLowerCase();

filesTypes.forEach((item, index) => {
	console.log('Index is  ', index);
	if(index === 4) {
  	return;
  }
});
// window.alert(allowedFileFormat('abc.EXE'));