JSFiddle - React, Tailwind, and code Playground
JavaScript
function countWays(n) {
if (n < 0) {
// All steps taken
return 0;
} else if (n === 0) {
// The first step of the staircase
return 1;
}
return countWays(n-1) + countWays(n-2) + countWays(n-3);
}
console.log(countWays(4));
/* var str = 'the pig tel';
var latin = str.split(' ');
for(var i=0;i<latin.length;i++){
latin[i] = latin[i].slice(1) + latin[i].slice(0,1) +'ay';
}
console.log(latin.join(' ')); */