Let’s write an improved version of the ‘Hello, world!’ program. Let’s ask the user in which language they want to see the message. You must have, at least, three different languages.
- If the user wants the message in Spanish, you have to log in the console “Hola, mundo!”.
- If the user wants the message in French, you have to log in the console “Bonjour tout le monde”.
- Finally, if we don’t have the indicated language, we will show “Hello, world!”.
Use the if…else and else if statements we have just learned
if( condition ) {
// do something
}
else if (condition ) {
// do something else
}
else {
// do this previous conditions were not true
}
For this simple exercise you may use codepen.io or repl.it.
Use the code below as your starting point.