Wordbox: add multiple words To: Montoya & Lostinbeta

Sorry i ask for the 2nd time but i can’t find a system to make entering different words give each their own result . I tried systems like this:

bluebutton.onRelease = function() {
if (wordbox.text == “cow”) {
// if the user typed cow
results.text = “the cow goes moo”;
// put moo in the lower box

bluebutton.onRelease = function() {
if (wordbox.text == “dog”) {
// if the user typed dog
results.text = “the dog eats a bone”;
// put bone in the lower box
} else {
results.text = “enter cow or dog for this to work”;
}
};
// just make sure you close your braces.
// Notice as well that we use == to mean “if the thing on the left is the same as the thing on the right”.
// We use the equal sign = to say… “the value of the thing on the left is the thing on the right”. That is why results.text=“goes moo”,
// because we assign that value to results.text.
//

Please reply (sorry for the 2nd time)

Well, that code should work!

bluebutton.onRelease = function() {
	if (wordbox.text == "cow") {
		// if the user typed cow
		results.text = "the cow goes moo";
		// put moo in the lower box
	} else if (wordbox.text == "dog") {
		// if the user typed dog
		results.text = "the dog eats a bone";
		// put bone in the lower box
	} else {
		results.text = "enter cow or dog for this to work";
	}
};

yours,
h88

**PS you can use the [*PHP]

(w/o the *) tags to add syntax highlighting and formatting to your code.**

for thouroughness sake, you could also use the switch command


bluebutton.onRelease=funtion(){

switch(wordbox.text){ // same as "if wordbox.text == "

case cow: //always end in colon

      results.text="this is for the cow";

break; //this says, now that you have your answer, stop checking.

case chicken:

      results.text="cluck, cluck, cluck";

break;

case turkey:

      results.text="days are numbered in November";
break;


I think this method is easier to understand and use.

Thanks for helping me out for the 2nd time!

Well, for thouroughness sake, Inigo, you should really put some “” in your cases :stuck_out_tongue:
case “cow”: //always end in colon
etc.

pom :cowboy: