I was experimenting and did a fibonocci number generator.
Just wanted to share.
var alist = [0, 1, 1, 2];
const add_it = (number, previous, alist, nth, start) => {
console.log(" ************* ")
//console.log(alist)
let next_number = previous + number;
let next_start = start + 1
if(next_start >= nth){
console.log("----------- final list ------------")
console.log(alist);
}
else {
alist.push(next_number);
console.log(alist);
add_it(next_number, number, alist, nth, next_start);
};
};
add_it(2, 1, alist, 15, 1);