# Decision Maker App Code

**URL:** <https://forum.code.org/t/decision-maker-app-code/40242>\
**Category:** CS Principles\
**Tags:** csp-unit-4\
**Created:** [December 16, 2024, 10:49pm UTC](https://forum.code.org/t/decision-maker-app-code/40242 "2024-12-16T22:49:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![slicky26atinsta](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@slicky26atinsta](https://forum.code.org/u/slicky26atinsta)\
**Post date:** [December 16, 2024, 10:49pm UTC](https://forum.code.org/t/decision-maker-app-code/40242/1 "2024-12-16T22:49:09Z")

</div>

One of my students is having trouble with their code, which Is not working. Is anyone able to help figure this out? Whenever any option is clicked, it results in an undefined in the output textbox for them. I have pasted their code below for anyone to see.

//Variables Used In Program  
var name;  
var price;  
var height;  
var sport;

//main code  
onEvent(“nameField”, “input”, function( ) {  
name = getText(“nameField”);  
updateScreen();  
setText(“output”, "Hey " + name + ". " + "The sport that is recommended that you should play is " + sport + “!”);  
console.log(“Code Works”);  
});  
onEvent(“priceDropdown”, “input”, function( ) {  
price = getText(“priceDropdown”);  
updateScreen();  
setText(“output”, "Hey " + name + ". " + "The sport that is recommended that you should play is " + sport + “!”);  
console.log(“Code Works”);  
});  
onEvent(“heightDropdown”, “input”, function( ) {  
height = getText(“heightDropdown”);  
updateScreen();  
setText(“output”, "Hey " + name + "! " + "The sport that is recommended that you should play is " + sport + “!”);  
console.log(“Code Works”);  
});

//Update Screen Function  
function updateScreen() {  
if (height == “\<5ft”) {  
sport = “Soccer”;

} else if (price == “$” && height == “\>=5ft”) {  
sport = “Basketball”;  
} else if (price == “$” && height == “\>=6ft”) {  
sport = “Basketball”;  
} else if (price == “$” && height == “\>=7ft”) {  
sport = “Basketball”;

} else if (price == “$$” && height == “\>=5ft”) {  
sport = “Soccer”;  
} else if (price == “$$” && height == “\>=6ft”) {  
sport = “Soccer”;  
} else if (price == “$$” && height == “\>=7ft”) {  
sport = “Basketball”;

} else if (price == “$$$” && height == “\>=5ft”) {  
sport = “Tennis”;  
} else if (price == “$$$” && height == “\>=6ft”) {  
sport = “Football”;  
} else if (price == “$$$” && height == “\>=7ft”) {  
sport = “Basketball”;

} else if (price == “$$$$” && height == “\>=5ft”) {  
sport = “Tennis”;  
} else if (price == “$$$$” && height == “\>=6ft”) {  
sport = “Tennis”;  
} else if (price == “$$$$” && height == “\>7ft”) {  
sport = “Tennis”;  
}  
}
