Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

build palindrome javascript

function solution(st) {
    let palindrome = st;
    let i = 0;
    while (palindrome !== palindrome.split('').reverse().join('')) {
        palindrome = st + st.slice(0, i).split('').reverse().join('');
        i++;
    }
    return palindrome;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #build #palindrome #javascript
ADD COMMENT
Topic
Name
3+5 =