Advertisement
Neri0817

pilindromeIntegers

Feb 8th, 2022
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function pilindromeIntegers(array) {
  2.   let isPilindrome = true;
  3.   for (let i = 0; i < array.length; i++) {
  4.     let num = array[i].toString();
  5.     let currentEl = num.split("");
  6.     let firstEl = currentEl[0];
  7.     let lastEl = currentEl.pop();
  8.  
  9.     console.log(firstEl == lastEl ? isPilindrome : !isPilindrome);
  10.   }
  11. }
  12. //pilindromeIntegers([123, 323, 421, 121]);
  13. pilindromeIntegers([32, 2, 232, 1010]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement