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


#1

how do i pass an argument from a function

https://www.codecademy.com/courses/learn-javascript/lessons/functions/exercises/return?action=lesson_resume
var orderCount = 0;
function takeOrder(topping,crustType){
console.log('Order:'+crustType+ ' pizza topped with '+ topping);
orderCount=orderCount + 1;
}
function getSubTotal(itemCount){
return itemCount*7.5;
}
takeOrder('bacon','thin crust');
takeOrder('bacon','thin crust');
takeOrder('bacon','thin crust');
console.log(getsubtotal(itemCount(7.5)));


#2

You mean how do i pass an argument to a function ?

suppose there is a function..

function sum(x,y) {return x + y;}

To use this function we need to call it and pass exact numbers of arguments to it as of number of parameters in it.
Now we see that it has two parameters(x and y) so we pass two arguments(values)

so we call the function and pass arguments(values) like this

sum(2,3);
It will return 5


#3

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