Answers for "find the missing value in an integer array javascript"

0

find the missing value in an integer array javascript

let a = [5, 7],
  count = 10,
  missing = []

for (let i = 1; i <= count; i++) {
  if (a.indexOf(i) === -1) {
    missing.push(i)
  }
}
console.log(missing)
Posted by: Guest on November-13-2020
0

The missing value javascript

var a = [5],
  count = 5;
var missing = new Array();

for (var i = 1; i <= count; i++) {
  if (a.indexOf(i) == -1) {
    missing.push(i);
  }
}
console.log(missing); // to check the result.
Posted by: Guest on September-28-2020

Code answers related to "find the missing value in an integer array javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language