Something Like that:
Find the missing number in Array
add this JS code.
JS
var myArray = [1,2,3,6,1];
//var myArray = [-1,-3];
var missingA;
for(var i=1;i<=myArray.length;i++)
{
if(myArray[i-1] != i){
missingA = i;
console.log(missingA)
//alert(missing);
break;
}
}
[codepen_embed height="265" theme_id="0" slug_hash="goJPXR" default_tab="js,result" user="pradeepanvi"]See the Pen Find the missing number in Array by Pradeep Kumar (@pradeepanvi) on CodePen.[/codepen_embed]
You can check console.