Functions Exercise 6 Return ||


#1

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

It gave me an error message like this: Did you put the getTotal() function call inside of a console.log statement? PLESAE I REALLY NEED SOMEONES HELP AS SOON AS POSSIBLE. I WANT TO LEARN JAVASCRIPT AS SOON AS POSSIBLE SO I WILL NOT LOSE MY JOB... SOME ONE SHOULD HELP ME PLEASE... THANK YOU..
Run

THIS IS THE CODE HERE:
var orderCount=0;
function takeOrder(topping,crustType){console.log('Order:'+ crustType +' topped with '+ topping+getSubTotal(1));orderCount=orderCount+1;}
function getSubTotal(itemCount){
  return(itemCount*7.5);
}


takeOrder('bacon','sandwich pizza');
takeOrder('bacon','meat pizza');
takeOrder('bacon','chicken pizza');
takeOrder('bacon','pork pizza');
console.log(getSubTotal(orderCount));
function getTax(){
  return getSubTotal((orderCount)*0.06);
 
 
}
function getTotal(){
    return getSubTotal(orderCount) + getTax();}
console.log (getTotal());


#2

Simple Answer: There is a space between log and the open parenthesis. That space is an error.

Other points: Your code is not the most readable and could be better organized. Readability is a huge part of being a programmer. It makes it easier to debug code or read it to understand it. Also, grouping functions together make them easier to find when you have a lot of code. See below example for details (it's your code with whitespace used to make it easier to read).

var orderCount = 0;

function takeOrder(toppings, crustType) {	
	console.log('Order: ' + crustType + ' topped with ' + toppings);
        orderCount++;
}

function getSubTotal(itemCount) {
  return(itemCount * 7.5);
}

function getTax() {
  return getSubTotal(orderCount) * 0.06; 
}

function getTotal() {
    return getSubTotal(orderCount) + getTax();
}

takeOrder('bacon', 'sandwich pizza');
takeOrder('bacon', 'meat pizza');
takeOrder('bacon', 'chicken pizza');
takeOrder('bacon','pork pizza');
console.log(getSubTotal(orderCount));
console.log(getTotal());  // <-- Removed the space between log and the opening parenthesis.

#3

Thank you so much. My code is working now. i still have another question for you. please where i am doing my internship now , they require me to learn ''Underscope.js'' as fast as possible. so i went to google and checked about it but everything seems so strange to me. please can you tell me what to do and how to learn this "Underscope.js". Sorry for bothering you.Thanks.


#4

I've never heard of underscope.js. Are you sure it's not underscore.js


#5

Sorry it was a typographical error. I am talking of Underscore.js.


#6

I haven't programmed with underscore.js. If I were going to start, I would treat it like any other things I want to learn. Look online for some resources on how to get started and code example until I feel comfortable enough to try to create a simple program and add more features to it as I learn more.

Here's another resource I thought was a quick read and useful: https://code.tutsplus.com/tutorials/getting-cozy-with-underscorejs--net-24581

I also recommend checkout YouTube videos.

I hope this helps.


#7

Thanks so much for your help. I already have accessed the website and the tutorial was really nice. At least now I know what Underscore.js is all about. I still need more in depth tutorial for underscore.js. I will do some searching on Google for other tutorials on this topic. Please if you still know of any other material or website which will help me to have more in depth understanding of this course I will really appreciate you letting me know. Anyway, thanks for your assistance. I really appreciate it.


#8

@pyninja79800 The word underscore.js is a link to underscore documentation. Be sure to check this out too.


#9

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