Window freezes on 6/13 when trying to submit code


#1

var orangeCost = function(number) {
console.log(orangeCost * 5);
orangeCost("$5")
}

Here's what I had... I don't know if this is what's causing the window to freeze.


#2

You call your function inside your function which again calls your function and so on (infinite loop).


#3

@javarockstar29414,

the FUNCTION talk

var myFunc = function( param1, param2) {
       //Begin of  anonymous FUNCTION-BODY
       //VARIABLE -myFunc- has an -anonymous function- assigned
       //this -anonymous function- has 2 PARAMETERS param1 and param2
       //param1 and param2 PARAMETERS are used 
       //as -local- VARIABLES throughout the FUNCTION-BODY

      console.log( param1 + " and " + param2 ) ;

      //End of anonymous FUNCTION-BODY
};

If you want to call/execute the anonymous function
you will have to add a pair of parentheses to the variable myFunc
like
myFunc();
As the anonymous function was defined
as having 2 parameters
you have to provide 2 arguments
in our case 2 string VALUES "Alena" and "Lauren"
like
myFunc("Alena","Lauren");

some quotes from the outer-world:

**argument is the value/variable/reference being passed in,
parameter is the receiving variable used within the function/block**

OR

**"parameters" are called "formal parameters",
while "arguments" are called "actual parameters".**


#4

@javarockstar29414,
As you could read in the function talk-post

the Instructions:

  1. You want to declare a function that calculates the cost of buying 5 oranges.
    • var function cost = orange-price * 5
  2. You then want to calculate the cost of the 5 all together.
    • var function cost = orange-price * 5
  3. Write a function that does this called orangeCost().
    • var orangeCost = function() { //function-body };
  4. It should take a parameter that is the cost of an orange, and multiply it by 5.
    • var orangeCost = function(cost) { cost * 5 };
  5. It should log the result of the multiplication to the console.
    • var orangeCost = function(cost) { console.log( cost * 5 }; }
  6. Call the function where oranges each cost 5 dollars.
    • orangeCost(5);

your code should be

var orangeCost = function( cost ) {
console.log(cost * 5);
} 
orangeCost(5);
console.log("my Code End");
//if there is any _displayed-output_ after this point
// it will be the course-checker giving some =output=

In words...
You have created a variable orangeCost
with an associated anonymous function Value
This anonymous function takes 1 parameter cost
If you are call-ing this anonymous function you will have to
attach a pair of parentheses-( ) to the variable orangeCost
like
orangeCost();
but as the anonymous function was defined as having 1 parameter cost
you will have to provide 1 argument
in our case that would be the number Value 5
like
orangeCost(5);


6.Don't Repeat Yourself (D.R.Y)
#5

You do not know a person who could explain it to me in Russian? The translator is a set of words (the meaning is lost, as if it is not present). I would really like pokantaktirovat with any person that I would show him that it is not clear. (Not necessarily Russian)