Passing a global variable to a function

前端 未结 5 1723
被撕碎了的回忆
被撕碎了的回忆 2020-12-03 03:41

How come the following code is giving me a 0 instead of a 1? I want my function to change a variable declared outside the function but I do not want to specify the variable

5条回答
  •  伪装坚强ぢ
    2020-12-03 04:17

    Actually you could just add console.log(input) inside the function and it would work just fine.

    Please correct me if i'm wrong. Hope i helped !!

    I would be glad if somebody could explain why im wrong

提交回复
热议问题