/..

Dark Mode

Enable Console

The Function

findCapitals('')
findCapitals(word)

/*
  Takes a single string as an argument and returns an ordered list 
  containing the indexes of all capital letters in the string.
*/

findCapitals('CodEWaRs');
// [0, 3, 4, 6]

findCapitals('NeeD4SwedE')
// [0, 3, 5, 9]

Solution by - Need4Swede

How it works

function findCapitals(word){

  // Initialize our index array
  let indexArr = [];

  // Split 'word' into an array of characters
  word.split("").forEach(function (char, index) {

    // If a character is in uppercase, and not a number, add index to our array
    if (char === char.toUpperCase() && isNaN(char)){
      indexArr.push(index);
    }
  });

  // Return the array
  return indexArr;
}

Try it yourself - Codewars Source

You can also use my built-in JavaScript console