Answers for "javascript remove negative numbers from array"

1

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]
Posted by: Guest on May-06-2021

Code answers related to "javascript remove negative numbers from array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language