Skip to content

Instantly share code, notes, and snippets.

@waqasraza123
Created January 11, 2023 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save waqasraza123/d5ddd7ec83642f87fe2cacd202575822 to your computer and use it in GitHub Desktop.
Save waqasraza123/d5ddd7ec83642f87fe2cacd202575822 to your computer and use it in GitHub Desktop.
const myString = "Hello World";
function reverse(myString){
let reversedString = ""
for(let i=myString.length - 1; i > 5; i--){
reversedString += myString.charAt(i);
}
return reversedString;
}
function reverse2(myString){
let reversedString = ""
for(let i=myString.length - 1; i > 5; i--){
reversedString += myString[i];
}
return reversedString;
}
reverse(myString); //outputs 'dlroW'
reverse2(myString); //outputs 'dlroW'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment