+ 1

Pls can i get a better solution to this problem?

I want to console.log the result of 512-282 dividing 47.48+5 This is my code but i am not satisfied with it. var x= 512; var y=282; var z=x-y; var a =47.48; var b=5; var c= a+b; console.log(z/c). Pls i need other ways to make the code reusable

13th May 2019, 8:19 PM
Bolaji Olayinka
Bolaji Olayinka - avatar
7 Antworten
+ 3
Here: function myMathFunction(x,y,a,b){ console.log((x-y)/(a+b)); } myMathFunction(512,282,47.48,5); Simply call the function and enter your numbers as arguments in the correct order https://code.sololearn.com/W8f3RAG4nqIU/?ref=app
13th May 2019, 8:39 PM
Decimis † 𝕯𝖊𝖈𝖎𝖒𝖎𝖘
Decimis † 𝕯𝖊𝖈𝖎𝖒𝖎𝖘 - avatar
+ 2
You can do the same thing with the line: console.log((512-282)/(47.48+5)); But what do you want to be reusable?
13th May 2019, 8:27 PM
Decimis † 𝕯𝖊𝖈𝖎𝖒𝖎𝖘
Decimis † 𝕯𝖊𝖈𝖎𝖒𝖎𝖘 - avatar
+ 1
Thanks. Reusable in the sense that i want to be able to pass different values in it other times
13th May 2019, 8:29 PM
Bolaji Olayinka
Bolaji Olayinka - avatar
+ 1
For each of the numbers
13th May 2019, 8:31 PM
Bolaji Olayinka
Bolaji Olayinka - avatar
+ 1
This is perfect
13th May 2019, 8:46 PM
Bolaji Olayinka
Bolaji Olayinka - avatar
+ 1
Thank u
13th May 2019, 8:56 PM
Bolaji Olayinka
Bolaji Olayinka - avatar
0
Different values for each of the numbers or only for certain ones?
13th May 2019, 8:30 PM
Decimis † 𝕯𝖊𝖈𝖎𝖒𝖎𝖘
Decimis † 𝕯𝖊𝖈𝖎𝖒𝖎𝖘 - avatar