Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

reverseString / Palindrome / Split string / Reverse Array

//reverseString
function reverseString(str){
    return str.split("").reverse().join("");
}
console.log(reverseString("Raymund"));

//FisrtName LastName reverse Display
function nameDisplay(fn,ln) {
    const fname = fn.split("").join("");
    const lname = ln.split("").join("");
const reverse = lname +" " + fname ; 
return reverse;

}
console.log(nameDisplay("Raymund", "Alum"));

//Palindrome
function palindrome(str) {

    var len = str.length;
    var mid = Math.floor(len/2);

    for ( var i = 0; i < mid; i++ ) {
        if (str[i] !== str[len - 1 - i]) {
            return str +" is Not Palindrome";
        }
    }

    return str + " is a Palindrome";
}
console.log(palindrome("Raymund"));

//Split string-->
function splitPhoneNum(num) {
var string = num
var phone = [string.slice(0, 3), " ", string.slice(3)].join('');
return phone;
}
console.log(splitPhoneNum("+919911568974"));



 //<--Reverse Array-->
var arr=[1,2,5,6,2];

res = arr.reverse();

console.log(res);

Comment

PREVIOUS NEXT
Code Example
Javascript :: save data response from fetch as global param js 
Javascript :: angular http post example 
Javascript :: javascript create anchor link 
Javascript :: html js hide or show iframe 
Javascript :: how to send headers using swr 
Javascript :: install svelte routing 
Javascript :: today tomorrow day after tomorrow button html and javascript 
Javascript :: cannon js parent child 
Javascript :: use params in Class based component 
Javascript :: redirect with data jquery 
Javascript :: how to learn react 
Javascript :: check when input number value goes up or down 
Javascript :: pdf.js get current page number 
Javascript :: execcommand image 
Javascript :: javascript multiple cases 
Javascript :: fetch is not defined jest react 
Javascript :: javascript object declaration 
Javascript :: You might have more than one copy of React in the same app. 
Javascript :: ask for expo token and save to firebase 
Javascript :: geojson featurecollection 
Javascript :: react native on refresh change color flat list 
Javascript :: coderbyte find intersection solutions 
Javascript :: javascript const 
Javascript :: leaflet geojson style stroke width 
Javascript :: emergency food 
Javascript :: Add select option by using <a in AngularJS 
Javascript :: How create a function that return element in js 
Javascript :: javascript append classname 
Javascript :: will console.log will be automatically disabled in react native for development build 
Javascript :: how to create an async function from a string in node js 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =