Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript remove negative numbers from array

var array = [18, -42, 21, 6, -50];
array = array.filter(function(x) { return x > -1; });
console.log(array); // [18, 21, 6]
 
PREVIOUS NEXT
Tagged: #javascript #remove #negative #numbers #array
ADD COMMENT
Topic
Name
4+2 =