Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve (number) {
- let num = [...number.toString()].map(Number);
- function sumOddAndEvenNum() {
- let oddSum = 0;
- let evenSum = 0;
- for (let i = 0; i < num.length; i++){
- if ( num[i] % 2 === 1){
- oddSum += num[i];
- } else {
- evenSum += num[i];
- }
- }
- return `Odd sum = ${oddSum}, Even sum = ${evenSum}`;
- }
- console.log(sumOddAndEvenNum());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement