I have one correction for you.
if(array.indexOf(4) >= -1 )
Needs to be:
if(array.indexOf(4) > -1 )
In order to check, whether an element is in the array. Otherwise the condition would always be true.
Yeah. indexOf() always return -1 if element is not found. Thanks Jonas
We’re a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.