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 trialAyan Kundu
1,194 Pointsi can't fix this problem i don't understand why this code is not working.
var Order = ''; var a = confirm(' Do you want to order Cold Coffee '); var b = confirm(' Do you Need Ice Cream '); if (a === true && b === true) { Order = ' I want cold coffee with ice cream '; } else if (a === true || b === false) { Order = " I want cold coffee but not ice cream "; } else if (a === false || b === true) { Order = ' I don\'t nedd coffee but i want to orer ice cream'; } else (a === false && b === false) { Order = ' No i don\' want any thing '; } function CoffeShop(a,b) { var AllOrder = Order; return AllOrder; } var Delivery = CoffeShop(a,b); document.write(Delivery);
Serhii Lihus
6,352 PointsYou forgot to put if in last condition.
var Order = '';
var a = confirm(' Do you want to order Cold Coffee ');
var b = confirm(' Do you Need Ice Cream ');
if (a === true && b === true) {
Order = ' I want cold coffee with ice cream ';
} else if (a === true || b === false) {
Order = " I want cold coffee but not ice cream ";
} else if (a === false || b === true) {
Order = 'I don\'t nedd coffee but i want to orer ice cream';
} else if (a === false && b === false) {
Order = 'No i don\'t want any thing ';
}
function CoffeShop(a,b) {
var AllOrder = Order;
return AllOrder;
}
var Delivery = CoffeShop(a,b);
document.write(Delivery);
2 Answers
Ayan Kundu
1,194 PointsBut the last statement should be only else. now even it's not working properly. else if (a === false && b === false) { Order = 'No i don\'t want any thing '; } is not working.
Ayan Kundu
1,194 PointsThe code should be like this .
var Order = ''; var a = confirm(' Do you want to order Cold Coffee '); var b = confirm(' Do you Need Ice Cream '); if (a === true && b === true) { Order = ' I want cold coffee with ice cream '; } else if (a === false && b === false) { Order = 'No i don\'t want any thing '; } else if (a === true || b === false) { Order = " I want cold coffee but not ice cream "; } else if (a === false || b === true) { Order = 'I don\'t nedd coffee but i want to ice cream'; }
Fernando Boza
25,384 PointsFernando Boza
25,384 PointsHI Ayan you can format your code by putting all the code with in middle, just remove the forward slashes.
//```javascript
//```
it would help other people view, read and help you better