<script> //Sum all the numbers from 1 to 10 //here's my hypothetical syntax. this is what i'd like my language to look like: //[1..10].sum().print(); //here's what it actually looks like in real javascript [...Array(11).keys()].slice(1).reduce((acc,cur) => acc + cur, 0); //here's the comparison between syntax for creating an array in hypothetical //vs current language //desired: [1..10] //actual: [...Array(11).keys()].slice(1) //the sum part is not as difficult, i could create that one //desired: [1,2,3,4,5,6,7,8,9,10].sum() //actual: [1,2,3,4,5,6,7,8,9,10].reduce((acc,cur) => acc + cur, 0) //////here's that working: //console.log([1,2,3,4,5,6,7,8,9,10].reduce((acc,cur) => acc + cur, 0)); Array.prototype.sum = function(){ var total = 0; for(var i = 0; i < this.length; i++){ total += this[i]; } return total; } //console.log([1,2,3,4,5,6,7,8,9,10].sum()); //this works! woohoo! part of the task done //the other part could be made more accomplishable by working within javascript syntax //so, make a range function that works like range(1,10) = [1,2,3,4,5,6,7,8,9,10] function range(start, end){ return [...Array(end+1).keys()].slice(start); } //console.log(range(1,10)); //two parts of the task are done. so now we can do console.log(range(1,10).sum()); </script>