javascript remove negative numbers from array

Solutions on MaxInterview for javascript remove negative numbers from array by the best coders in the world

showing results for - "javascript remove negative numbers from array"
Tiphaine
12 Oct 2018
1var array = [18, -42, 21, 6, -50];
2array = array.filter(function(x) { return x > -1; });
3console.log(array); // [18, 21, 6]