This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Function Revesred Integer | |
function mtdNumberReverse(n){ | |
let reversed = n.toString().split('').reverse().join('') | |
reversed = parseInt(reversed) | |
if(n < 0){ | |
return reversed * -1 | |
} | |
return reversed | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Palindrome Algorithm | |
// Method A | |
function mtdPalindromeA(str){ | |
str = str.toLowerCase() | |
return( str.toLowerCase() === str.split('').reverse().join('') ) | |
} | |
mtdPalindromeA('Appa') | |
mtdPalindromeA('am i a palindrome') | |
// String Palindrome |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Reverse a string using reverse Method | |
function reverseStringMtd(str) { | |
return str | |
.split('') | |
.reverse() | |
.join('') | |
} | |
// Reverse a String using for Loop Method | |
function reverseLoopMtd(strChar) { |