Ad
Code
Diff
  • function removeEveryThird(str) {
      return str
        .split('')
        .filter((x, i) => i === 0 || i % 3)
        .join('')
    }
    • function removeEveryThird(str) {
    • const strArr = str.split('');
    • const newArr = [];
    • strArr.forEach((char, index) => {
    • if (index === 0 || index % 3 !== 0) {
    • newArr.push(char);
    • }
    • })
    • console.log(newArr.join(''));
    • return newArr.join('');
    • return str
    • .split('')
    • .filter((x, i) => i === 0 || i % 3)
    • .join('')
    • }