Can't "Call" a function with console.log?


#1

I am having a lot of trouble calling the function I am describing in the "5 orangeCost" exercise. It also says I am not defining orangeCost. PLEASE HELP. Been stuck for hours.


#2

try:

orangeCost(5);

#3

I think that I may have the whole code wrong...

Any tips on how to format from the beginning ??


#4

Well just note that a function is written in this format:

var example = function(/*Parameter*/){ ... }

Then you call that function by giving the function a parameter like so:

example(/*parameter*/);

Pay close attention to the instructions the lessons give you and see if you can figure stuff out from there :smiley:


#5

I know the format but I think the language I am using to represent "calculating the 5 oranges" and the language I am using the log the result is Incorrect! Any more advice? On diction more so?


#6

Can you show me your current code so I can see what exactly it is that you're struggling on?


#7

var calculate = function (orangeCost) {
var calculate = function (orangeCost * 5 === price);
console.log(price);
}


#8

Hi @edenteferi

If it may help please see the code example below. There are a few errors with your code to start and also the reason you are getting the error on the unit lesson is probably because you have not used the name orangeCost for your variable. Please review the following code to compare against.

var orangeCost = function(costOfOrange)  //use term orangeCost here and declare it as a function
{
    console.log(costOfOrange *5); //use the argument passed in under the term costOfOrange to calculate on, and print it to console
};

orangeCost(5); //call the function here and pass in your value for the function to use

#9

Wow, thank you SO much @mike_in_training

I think I just completely blanked on that format, I appreciate you explaining this SO much, thank you.


#10

try multiplying 5 by price so it looks like this (price*5)