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 }

21st Jul 2022, 9:39 PM
Joshua Ukaka
Joshua Ukaka - avatar
6 Answers
+ 8
Sure! Can you please show us your code attempt so we can check on it?
21st Jul 2022, 9:48 PM
Lisa
Lisa - avatar
+ 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.
22nd Jul 2022, 10:36 AM
Lisa
Lisa - avatar
+ 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.
21st Jul 2022, 10:20 PM
Ian James
+ 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);
23rd Jul 2022, 5:29 AM
Junior
Junior - avatar
0
Alright Thanks a lot
22nd Jul 2022, 6:49 PM
Joshua Ukaka
Joshua Ukaka - avatar
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();
23rd Jul 2022, 5:25 AM
Junior
Junior - avatar