Help with javaScript


These are the instructions that code academy gives

You are a creature of habit. Every week you buy 5 oranges. But orange prices keep changing!

You want to declare a function that calculates the cost of buying 5 oranges.
You then want to calculate the cost of the 5 all together.
Write a function that does this called orangeCost().
It should take a parameter that is the cost of an orange, and multiply it by 5.
It should log the result of the multiplication to the console.
Call the function where oranges each cost 5 dollars.

Now I dont exactly know where to start I would appreciate any help


Are you looking for help with `

Java or JavaScript



It's JavaScript, More specifically, could you post your code, and the issue you're having in a more specified degree? This will allow us to help you through the trouble spots and help you learn at the same time.


This is what I have

var orangeCost = function(cost){
amount = 5;
orangeCost(amount, 5);



Alright take a look at example 1:

Example 1:

var orangeCost = function(cost){

This line is establishing a function "orangeCost" with one parameter of "cost".
Meaning when you call this function you will put in one parameter for the function to work with.

However, in example two, you can see you are passing the orangeCost function two parameters.

Example 2:

orangeCost(amount, 5);

The function is looking at this and saying.. "What the poop do I do with this second parameter??"


You have to take out one of the parameters that you're passing the function.

amount = 5;

or you can simplify it to just


Either way will work, but not both at the same time.

Extra information:

Functions have parameters that can be separated in the function as follows:

var example = function(parameter, parameter2, parameter3, etc...) {...}

If you wanted to have more parameters in a function you can add them. But it's most efficient to use only the parameters you have distinguished to the function for maximum efficiency.


Thank you guys for the help!