Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

daniel zaragoza
daniel zaragoza
1,843 Points

Please Critique my code

Im still in the beginning stages of JavaScript where I'm just starting to learn about functions and how they work. Since, I'm the type who learns more by doing then watching. I decided to try re-create price is right and this i what i came up with.

function gameShow(user1,user2,user3){ alert(" Welcome to the Price is Right bootleg editon! ") var couch = 200; var player1 = prompt( user1 + " Please enter the amount you think this couch is worth "); var player2 = prompt( user2 + " Please enter the amount you think this couch is worth "); var player3 = prompt( user3 + " Please enter the amount you think this couch is worth "); if(parseInt(player1) === couch || parseInt( player1) > parseInt(player2) && parseInt(player1) > parseInt(player3)){ player1 = true;
//alert( user1 + " Let's Play! "); }else if(parseInt(player2) === couch || parseInt(player1) parseInt(player3) ){ player2 = true; //alert(user2 + " Let's Play! "); }else if(parseInt(player3) === couch || parseInt(player1) player3 = true;
//alert(user3 + " Let's Play! "); } if(player1 ===true){ alert( user1 + " Let's play "); }else if( player2 === true){ alert( user2 + " Let's play "); }else if(player3 === true ){ alert(user3 + " Let's play ");
} }
gameShow('Kat', 'John', 'Betty');

There are some issues with both of your "else if" statements. There are missing brackets and the right-side (right of the || ) is missing any evaluating operator. I threw some in and got it to run in the console.