You can comment your solutions for given problems in your preferred language.
const reverseString = (str) =>{
return str.split('').reverse('').join('');
}
console.log(reverseString('text'));
console.log(reverseString('string'));
Output:
- "txet"
- "gnirts"
2] Factorialize
const factorialOfNumber = (num) =>{
let fact = 1;
if(fact === 0){
return 0;
}
for(let i=1; i<=num; i++){
fact = fact*i;
}
return fact;
}
console.log(factorialOfNumber(5));
console.log(factorialOfNumber(0));
Output:
- 120
- 1
3] Pallindrome check
Comments
Post a Comment