📌  相关文章
📜  在两个偶数之间放置破折号 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:21.386000             🧑  作者: Mango

代码示例1
function insertHyphen(str) {
  var strArr = str.split('');
  var numArr = strArr.map(Number);
  for(var i = 0; i < numArr.length; i++) {
   if(numArr[i-1]%2===0 && numArr[i]%2===0) {
        numArr.push('-');
    }
  }
  return numArr.join('');
}
insertHyphen('112233445566'); // 112233445566---