+ 1
Javascript Subtraction
Help me It does all fine but at 7th line 3,4,5 words aren't working fine! It should have Input where you put as many numbers as you want than it outputs it's subtraction function Subtract(Input){ var Input; var INS = Input.split(" ") var output; var outputI = INS[1] for (let i = 1; i <INS.length; i++) { outputI = outputI - INS[i] } output = outputI return output } console.log(Subtract("3 2")) //Ans should be 1 but isnt
1 Answer
+ 2
In your code you are subtracting starting from the second input:
var outputI = INS[1]
INS[1] is the second input, change it to INS[0] and your code will work perfectly.