Spocoman

02. Negative or Positive Numbers

Feb 5th, 2022 (edited)
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function negativeOrPositiveNumbers(arr) {
  2.     let result = [];
  3.  
  4.     for (let i = 0; i < arr.length; i++){
  5.         arr[i] < 0 ? result.unshift(arr[i]) : result.push(arr[i]);
  6.     }
  7.     console.log(result.join('\n'));
  8. }
  9.  
Add Comment
Please, Sign In to add comment