you are still making the same mistake here, leaving out the if:
Code:
else (pronoun === yo && type === i) {
alert(first + "o");
};
aside from that pronoun is a variable and yo is a string, so it should be
Code:
pronoun === "yo"
i is a string too, so that should be type === "i" as well
oh - and you're still putting the semi colons after the ending brace of the if statement. What's the point in asking questions if you're not going to listen to the answers?
... but you are going to end up with an insanely long list of if/elses. Here's a shortcut that you might be interested in:
Code:
<script type="text/javascript">
var pronoun = prompt("What is your pronoun(put yo, tu, el, etc.)");
var verb = prompt("What is your verb");
var last = verb.substring(verb.length-2)
var first = verb.substring(0,verb.length-2)
var type = verb.substring(verb.length-2,verb.length-1);
var verbs={yo:{a:"o",e:"e",i:"o"},
tu:{a:"as",e:"as",i:"is"}
}
alert(first+verbs[pronoun][type])
</script>
now all you have to do is figure out how to code the irregulars
you have a 2 simple errors in your code
the first one as xelawho said all variables in your code are string, so they should be marked like this
pronoun === 'yo' or pronoun === "yo"
and so for
type === 'a' or type === "a"
second error at last part of code
else (pronoun === 'yo' && type === 'i')
because last eles desn't need a condition
else {........}
or make it else if
eles if(pronoun === 'yo' && type === 'i') {........}
so your code will be like this
var pronoun = prompt("What is your pronoun(put yo, tu, el, etc.)");
var verb = prompt("What is your verb");
var last = verb.substring(verb.length-2);
var first = verb.substring(0,verb.length-2);
var type = verb.substring(verb.length-2,verb.length-1);
if (pronoun === 'yo' && type === 'a') {
alert(first + "o");
};
else if (pronoun === 'yo' && type === 'e') {
alert(first + "e");
};
else if (pronoun === 'yo' && type === 'i') {
alert(first + "o");
};
I'm not criticizing you and I think it's great that you're getting into coding so early. You will be a total ninja by the time you are 20 if you keep going. But if you are going to ask questions it's polite to read the answers and try not to repeat the same mistake. Doesn't matter how old you are, and anyway you will learn faster that way.
In the code I showed you verbs is an object (pretty much everything in javascript is an object, so you should get used to working with them).
Objects have keys and keys have values. Yo, tu, el, etc are keys, but here each value is another object. Within the yo object a, e and i are keys and "o", "e" and "o" are their respective values.
You can access an object's values in two ways: dot notation -
Code:
alert(verbs.yo.a) // returns "o"
or array notation -
Code:
alert(verbs["yo"]["a"]) // returns "o"
They return the same thing, but if you are trying to access object values with variables (as you do in your code) you can't use dot notation, but you can use array notation. In plain English, this:
Code:
verbs[pronoun][type]
says return the value corresponding to the key that matches the "type" variable from the object that matches the "pronoun" variable from within the verbs object.
which I guess is not so plain, but that's as best I can explain it.
Bookmarks