Comparing Variables App Lab

Students are trying to compare the variables values to switch to a recommend screen.
We can’t figure out what the issue is.
Any thoughts would be helpful and appreciated
The first selection work, but the others do not, we have tried > and the && and the || without success.

[App Lab -](https://Link to project)

May you describe the problem more specifically?

The user of the project should be able to select the buttons on the various screens. The buttons add value to the variables.
At the final screen, the user should select “recommend” and the project should recommend a “player” based on the variable that has the greatest value.
When we run the project, we are not directed to the screen with the greatest variable value, we are only directed to “Alex”
cant figure it out

Instead of checking the value of each variable seperately as was attempted in the code, you should include them in an array and iterate through the array elements. I changed your recFunction. It works perfectly now.

function recFunction() {
  var highest;
  var highestScore=0;
  var choices=[widowmaker,ghost,pyramidhead,chunli,bayonetta,cloud,jetstreamsam,alex];
  var names=["Widowmaker","Ghost","PyramidHead","ChunLi","Bayonetta","Cloud","JetSam","Alex"];
  for (var i=0; i<choices.length; i++){
    if (choices[i]>highestScore){

Hi @mriley,

@ismailmf777 has a good solution but I’m guessing your students might not be familiar with arrays. Boolean expressions need 2 arguments to evaluate to true or false - this is why your code may not be working. To simplify the problem within the skill-set your students are familiar with, you can set the first variable to the max value and then compare that to the other values. An example might be:

//Initialize the maximum value variable
max_val = alex

//compare each value to the max value.
if cloud > max_val:
max_val = cloud
if chunli > max_val:
max_val = chunli
if bayonetta > max_val:
max_val = bayonetta
if ghost > max_val:
max_val = ghost
if jetstreamsam > max_val:
max_val = jetstreamsam
if pyramidhead > max_val:
max_val = pyramidhead
if widowmaker > max_val:
max_val = widowmaker

Within each if statement, you can show the sprite for the max_val. By the end of the series of if statements, the correct sprite should be showing.

Good luck!

Thank you both for these responses! Both are VERY helpful and very appreciated!