+ 1

Js functions

function test(a,b){ return (a,b); } function values(){ var d = test(5,6); return d; } function calc(){ var c = test(arguments [0]) * test(arguments [1]); return c; } console.log(calc()); /*Output NaN */ Output is supposed to be 30, can anyone help pls?

27th Apr 2019, 2:04 PM
Oluwasegun Are
Oluwasegun Are - avatar
4 Respostas
+ 4
Oluwasegun Are I understand values() purpose, my question to you is where in your code do values() get invoked to pass any value in a and b. In the calc() function instead of invoking test(), the values() function can be invoked thus invoking the test function and passing 5 and 6 to it(test()) Now for the test() function where you are trying to return the values that were passed to it. This can be done but instead of trying to return two separate numbers you need to return the arguments object https://code.sololearn.com/W2M1Bha8y7Py/#js
27th Apr 2019, 3:30 PM
ODLNT
ODLNT - avatar
+ 4
When does the function values() get invoke?
27th Apr 2019, 2:13 PM
ODLNT
ODLNT - avatar
+ 1
Thanks
27th Apr 2019, 3:53 PM
Oluwasegun Are
Oluwasegun Are - avatar
0
It's is to accept values to be stored in a and b
27th Apr 2019, 2:18 PM
Oluwasegun Are
Oluwasegun Are - avatar