Why this code doesn't work? | Sololearn: Learn to code for FREE!

+9

# Why this code doesn't work?

https://code.sololearn.com/WdOS55uWBDqi/?ref=app

4/8/2021 9:27:04 AM

Тимур Завьялов

+4

console.log( [ "Even", "Odd" ] [ a % 2 ] ); It's an array with conditional index. The `a % 2` expression evaluates to 0 when <a> is an even number, and 1 when <a> is odd number. The evaluation result of `a % 2` is used to decide which element is chosen from the array, to be printed into the console.

+5

Good stuff. [ a % 2] returns 0 or 1, and that takes "Even" or "Odd". ...talking to myself :)

+4

Sample Output: "0 is even" "1 is odd" "2 is even"

+4

Vasiliy You are an excellent programmer, I like your excellence and the cleanliness of your codes. Input: "2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50 etc" Output: even Input: "1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49 etc" Output: odd 𝙶𝚛𝚎𝚎𝚝𝚒𝚗𝚐𝚜 𝚍𝚎𝚊𝚛 𝚏𝚛𝚒𝚎𝚗𝚍ヅ

+1

Ipang, thank you)

+1

+1

Juan Angel Luzardo Muslera Another example of the output ☺️ Input: " " Output: even

+1

Тимур Завьялов https://code.sololearn.com/WdOS55uWBDqi/?ref=app The CoDe complete, 😁😁

0

No problem bro 👌

0