0
Can anyone help me with the code function in JavaScript that takes a parameter and outputs its double. This is the code.
Function double() { Output num*2 }
6 ответов
+ 8
Sure! Can you please show us your code attempt so we can check on it?
+ 3
From your profile I can see that you did the Web Development Fundamentals courses.
Please have a look at lesson 33.1 on functions again, especially the section with the heading "Parameters". Also take a close look at the spellings of keywords, for example it is "function", not "Function".
If you need more help, you can show us your updated code here.
+ 2
Remember that JavaScript tries to guess what data type you want to use, so if it guesses wrong then you can use what's called "implicit type coercion" to tell it use the right type.
+ 1
Also you could do this:
//x is paramater name
function demo(x) {
/*amazing now that its defined and the hard step is over we can just console.log and multiple it by 2!! */
console.log(x * 2)
}
/*Like how i did x = 2 this is just that pretty much but 2 = x i guess is how i think of it this way */
demo(2);
0
Alright
Thanks a lot
0
Im not gonna just give you the answer but i will help u alonf the way.
// x is the parameter name
function demo(x) {
/*since x is undefined lets define it ;-; */
x = 2;
/*amazing now that its defined and the hard step is over we can just console.log and multiple it by 2!! */
console.log(x * 2)
}
/*DONT FORGET TO CALL THE FUNCTION */
demo();