+ 1

Function Parameters

I was wondering with function parameters could you use something like a prompt to insert a value directly into the function instead of making a var. To make it clear I will make a demonstration So if I set function MyFunction(a,b) could I insert a value into a or b with a prompt or something else, without doing "(MyFunction(20,40))". So the user can submit the information without going into the code itself to submit it. I am sorry if I did not make my point clear I am trying to understand everything with functions. Thank you for helping and if you don't understand what I am trying to ask that is my fault not yours :).

6th Apr 2018, 6:37 PM
Bradley
1 Réponse
+ 2
https://code.sololearn.com/W0Z2CA5r9gSz/#html <script> // Obtain input from user and store for use let a = Number(prompt("Enter A: ")); let b = Number(prompt("Enter B: ")); // Call our function and feed it our input myFunction(a,b); // Our function - add the numbers and display to user function myFunction(a,b){ alert(a+b); } </script>
6th Apr 2018, 7:39 PM
Fata1 Err0r
Fata1 Err0r - avatar