Advertisement
Spocoman

06. Even and Odd Subtraction

Jan 20th, 2022
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     let sum = 0;
  3.     for(let i = 0; i < input.length; i++ ){
  4.         Number(input[i]) % 2 === 0 ? sum += Number(input[i]) : sum -= Number(input[i]);
  5.     }
  6.     console.log(sum);
  7. }
  8.  
  9.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement