Friday, 6 September 2013

[Java]High school level Spanish 1 & 2 translator bug(made using labs.codeacademy.com)

[Java]High school level Spanish 1 & 2 translator bug(made using
labs.codeacademy.com)

I am making a high school level Spanish 1 & 2 translator but I have run
into a bug; After you are prompted for the word, instead of just giving
you the translation it prints out the entire list of translations.
I am using my basic java knowledge gained from the site Codeacademy.com
and can not figure out what causes this bug.
P.S. If you can help me in making this process with the if statements
easier and quicker I would greatly appreciate it.
Code:
var word = prompt("Word to translate(lower case only):");
//English
var hi;
var white;
//Translate
var hola = hi;
var blanco = white;
var translate = function(word)
{
return word;
};
//Spanish to English
if(translate() === hola)
{
console.log("hi");
}
if(translate() === blanco)
{
console.log("white");
}
//English to Spanish
if(translate() === hi)
{
console.log("hola");
}
if(translate() === white)
{
console.log("blanco");
}

No comments:

Post a Comment