Last active
September 2, 2022 06:42
-
-
Save damdafayton/409d955d2f9d6f7c989f5686001f8c32 to your computer and use it in GitHub Desktop.
Akbank Web3 Practicum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sumOddOrEven(num){ | |
return num.toString().split('').reduce((prev,cur)=> parseInt(prev, 10) + parseInt(cur, 10)) % 2 === 0 ? 'Even' : 'Odd' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bir sayının Tek mi Çift mi olduğunu belirleyen bir işlev oluşturun. Bir sayı, tüm basamaklarının toplamı tek ise tek, tüm basamaklarının toplamı çift ise bir sayıdır. Bir sayı tek ise, "Odd" döndürün. Aksi takdirde, "Even" değerini döndürün. Örnek olarak:
oddishOrEvenish(43) ➞ "Odd"
// 4 + 3 = 7
// 7 % 2 = 1
oddishOrEvenish(373) ➞ "Odd"
// 3 + 7 + 3 = 13
// 13 % 2 = 1
oddishOrEvenish(4433) ➞ "Even"
// 4 + 4 + 3 + 3 = 14
// 14 % 2 = 0