Created
December 1, 2017 02:58
-
-
Save rodpoblete/9088d8b5752116fbab69fa8f8f8d9684 to your computer and use it in GitHub Desktop.
Write a function that takes a single string (word) as argument. The function must return an ordered list containing the indexes of all capital letters in the string.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Instructions | |
// Write a function that takes a single string (word) as argument. The function must return an ordered list containing the indexes of all capital letters in the string. | |
// Test.assertSimilar( capitals('CodEWaRs'), [0,3,4,6] ); | |
const capital = function(word) { | |
const arr = word.split(""); | |
const arrOrdened = arr.map(function(e, i, a) { | |
if (e === e.toUpperCase()) { | |
return i; | |
} | |
}); | |
console.log(arrOrdened); | |
}; | |
capital("CodEWaRs"); |
cristofer-dev
commented
Dec 1, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment