第30天 [js]写一个方法判断字符串是否为回文字符串

//写一个方法判断字符串是否为回文字符串
function getMaxMin() {  
    let a = "s a    d a s a"
    //实现思路,不考虑大小写的情况下,先转换成小写,然后用空格split分格数组,再通过数组的reverse转换顺序,再用join链接
    let b = a.replace(/[^a-zA-Z0-9]/g, "").toLowerCase()
    console.log(b);
    const strReverse = b.split('').reverse().join('')
    console.log(strReverse == a);
   }
getMaxMin()

  

原文地址:https://www.cnblogs.com/DIVEY/p/15570796.html