Liliana797979

polindrome fundamentals

May 12th, 2021
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. function polindrome(arr) {
  3.     let result = "";
  4.     for (let num of arr) {
  5.         let isPolindrome = `true`;
  6.         num = String(num);
  7.         let mid = parseInt(num.length / 2);
  8.         for (let i = 0; i <= mid; i++) {
  9.             let lastIndex = num.length - 1;
  10.             if (num[i] !== num[lastIndex - i]) {
  11.                 isPolindrome = `false`;
  12.                 break;
  13.             }
  14.         }
  15.         result += isPolindrome + `\n`;
  16.         }
  17.         return result;
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment