Mars Exploration

  • + 0 comments

    Js solution:

    return s.split('').reduce((accumulator ,letter, currentIndex: number) => {
        if(
            ((currentIndex%3 === 0 || currentIndex%3 === 2) && letter !== 'S') ||
            (currentIndex%3 === 1 && letter !== 'O')
        ){
            return accumulator += 1;
        }
        return accumulator;
    }, 0);
    

    }