didkoslawow

Untitled

Sep 30th, 2022
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. function multiplyBy2(input) {
  2. let num = 0;
  3.  
  4. for (i = 0; i < input.length; i++) {
  5. num = Number(input[i]);
  6. num *= 2;
  7. if (Math.sign(num) === 1) {
  8. console.log("Result: " + num.toFixed(2));
  9. i++;
  10. } else {
  11. console.log("Negative number!");
  12. }
  13. }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment