Can You Translate?!
After receiving a message on WhatsApp from an unfamiliar number, you wonder if it's from the person with a foreign accent you met last night. Your task is to write a simple function that checks for various translations of the word "hello" in different languages.
Here are the translations in the languages spoken by the people you encountered:
hello - english
ciao - italian
salut - french
hallo - german
hola - spanish
ahoj - czech republic
czesc - polish
Notes:
Assume that the input will always be a string.
To keep this exercise beginner-friendly, there's no need to check if the greeting is part of another word (e.g., "Halloween" should still pass the test).
The function should be case insensitive in order to pass the tests.
Check out my solution below:
function validateHello(greetings) {
for (let str in greetings){
let res = str.toLowerCase();
if (res == "hello") {
return true;
} else if (res == "ciao") {
return true;
} else if (res =="salut") {
return trres;
} else if (res == "hallo") {
return true;
} else if (res == "hola") {
return true;
} else if (res == "ahoj") {
return true;
} else if (res == "czesc") {
return true ;