Day 86: String Reversal Using Recursion of 100DaysCodingChallenge
Hello all,
#day86
Day86
Today's task was to write a program to reverse a string entered by the user using Recursion.
I have started the 100 days of coding challenge to improve my programming skills..
Code :
let s = prompt("Enter a String : ");
function StringRev(text) {
if (text.length == 1) {
return text;
}
else {
return text.slice(-1) + StringRev(text.slice(0, -1));
}
}
//StringRev(“SessionStack”);
console.log(StringRev(s));
Output :
Happy Coding:)
Thank you...

Comments
Post a Comment