Javascript, functions, return. what's wrong with my code?


#1

https://www.codecademy.com/courses/learn-javascript/lessons/functions/exercises/return-ii?action=lesson_resume&link_content_target=interstitial_lesson

Can't figure out what's wrong with my code. It doesn't post what I want in the editor.

var orderCount = 0;
function takeOrder(topping, crustType){
orderCount = orderCount + 1;
console.log('Order: ' + crustType + ' pizza topped with ' + topping);
}
function getSubTotal(itemCount){
return getSubTotal((itemCount) * 7.5);
}
function getTax(){
return getSubTotal((orderCount) * 0.06);
}
function getTotal(){
return getSubTotal(orderCount) + getTax();
}
takeOrder('bacon', 'medium crust');
takeOrder('pineapple', 'thin crust');
takeOrder('cheese', 'thick crust');
console.log(getSubTotal * orderCount);
console.log(getTotal());


#2

i figured it out myself. the code should be:

var orderCount = 0;
function takeOrder(topping, crustType) {
orderCount = orderCount + 1;
console.log('Order: ' + crustType + ' pizza topped with ' + topping);
}
function getSubTotal(itemCount) {
return itemCount * 7.5;
}
function getTax(){
return getSubTotal(orderCount) * 0.06;
}
function getTotal() {
return getSubTotal(orderCount) + getTax();
}
takeOrder('bacon', 'medium crust');
takeOrder('pineapple', 'thin crust');
takeOrder('cheese', 'thick crust');
console.log(getSubTotal(orderCount));
console.log(getTotal());


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.