Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Find a palindrome using Array methods

let str = "civic";
let strReverse = str.split("").reverse().join("");

if (str === strReverse) {
  console.log("The string is a palindrome");
} else {
  console.log("NOT a palindrome");
}
Comment

palindromes array number

function isPalindrome(N) 
{
          str = " " + N;
          len = str.length;
          for (var i = 0; i < len / 2; i++)
          {
               if (str[i] != str[len - 1 - i])
                    return false;
          }           
      return true;
}

function isPalinArray(arr,n)
{
  var counter = 0;
  for (var i = 0; i < n; i++)
  {
    ans = isPalindrome(arr[i]);
    if (ans == true)
         counter++;

  }
  console.log("Number of Palindromes in the array:" + counter);

}

arr = [123, 121];
n = arr.length;

res = isPalinArray(arr, n);

Comment

PREVIOUS NEXT
Code Example
Javascript :: convert File to multer file js 
Javascript :: vue format number as dollars 
Javascript :: jQuery - The noConflict() Method 
Javascript :: Function As Parameter In Self Invoking Function 
Javascript :: array string to length number 
Javascript :: solo letras js 
Javascript :: destructuring function nested parameters 
Javascript :: Create Own Variable As "Constructor Function" 
Javascript :: wind in mongoose 
Javascript :: aboutreact axios 
Javascript :: js extend list 
Javascript :: converting JSON to jsObject 
Javascript :: Javascript Recursion shuffle card 
Javascript :: vs code shortkey to launch snippet 
Javascript :: lwc format date js 
Javascript :: unreachable code detected javascript 
Javascript :: modify summernote with js 
Javascript :: Get Error 
Javascript :: Naming Your Componts Vue 
Javascript :: nextjs youtube embed 
Javascript :: react js public folder image path search 
Javascript :: convert functional to class component online 
Javascript :: input change angular event 
Javascript :: remove element 
Javascript :: modify an array in javascript using function method 
Javascript :: nodejs version abfragen 
Javascript :: mongodb-nodejs-driver-deprecationwarning-collection-count-is-deprecated 
Javascript :: How to write "Hello World" 
Javascript :: node js rest with flutter 
Javascript :: get id of click element within a class list jquery 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =