The Switch Statement ( Coding challenge ) Flashcards
1
Q
Use a switch statement to log the following string for the given ‘language’:
chinese or mandarin: ‘MOST number of native speakers!’
spanish: ‘2nd place in number of native speakers’
english: ‘3rd place’
hindi: ‘Number 4’
arabic: ‘5th most spoken language’
for all other simply log ‘Great language too :D’
A
switch (language) { case 'chinese': case 'mandarin': console.log('MOST number of native speakers!'); break; case 'spanish': console.log('2nd place in number of native speakers'); break; case 'english': console.log('3rd place'); break; case 'hindi': console.log('Number 4'); break; case 'arabic': console.log('5th most spoken language'); break; default: console.log('Great language too :D'); }