Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

check if all values in array are zero javascript

function zeroTest(element) {
  return element === 0;
}

var array = [0, 0, 0, 0];
var allZeros = array.every(zeroTest);

console.log(allZeros);

array = [0, 0, 0, 1];
allZeros = array.every(zeroTest);

console.log(allZeros);
 Run code snippetHide results
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #check #values #array #javascript
ADD COMMENT
Topic
Name
5+6 =