diff --git a/es6/let_keyword.js b/es6/let_keyword.js index a91bb0b..1d09fd8 100644 --- a/es6/let_keyword.js +++ b/es6/let_keyword.js @@ -64,3 +64,33 @@ fs.forEach(function (f) { // 7 // 8 // 9 + +function varFunc(){ + var previous = 0; + var current = 1; + var i; + var temp; + + for(i = 0; i < 10; i+=1){ + temp = previous; + previous = current; + current = temp + current; + } + console.log(current); +} + +function letFunc(){ + let previous = 0; + let current = 1; + + for(let i = 0; i < 10; i+=1){ + let temp = previous; + previous = current; + current = temp + current; + } + + console.log(current); +} + +varFunc(); +letFunc();