Hello all,
I just ran into a weird issue about the keyword let being rejected due to it being a part of es6. I did some googling and found this post on S/Ohttps://stackoverflow.com/questions/27441803/why-does-jshint-throw-a-warning-if-i-am-using-const
suggesting to add the following comment to my code to fix it.
/*jshint esversion: 6 */
So I get that it works. But I don’t get why it works. Does anyone know?
Your code so far
function sumAll(arr) {
let total = 0;
let smallest = Math.min(arr[0],arr[1]);
let largest = Math.max(arr[0],arr[1]);
let totalArr = [];
while(smallest <= largest){
total+=smallest;
smallest+=1;
}
// total = totalArr.reduce(function(first,next){
// return first+next;
// });
return total;
}
sumAll([1, 4]);
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36
.
Link to the challenge: