Answers for "remove negative sign from number javascript"

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
0

remove negative sign from number javascript

Math.abs('the negative number')
Math.abs(-4)//returns 4
Math.abs(4)//returns 4
Posted by: Guest on September-28-2021

Code answers related to "remove negative sign from number javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language