Skip to content

Instantly share code, notes, and snippets.

@CoGrammarCodeReview
Created August 2, 2022 14:42
Show Gist options
  • Save CoGrammarCodeReview/d49c837f7b170b8a6c6fdcd5170e4e91 to your computer and use it in GitHub Desktop.
Save CoGrammarCodeReview/d49c837f7b170b8a6c6fdcd5170e4e91 to your computer and use it in GitHub Desktop.
String Challenge
Create a function that, given a string with at least three characters, returns an array of its:
Length.
First character.
Last character.
Middle character, if the string has an odd number of characters. Middle TWO characters, if the string has an even number of characters.
Index of the second occurrence of the second character in the format "@ index #" and "not found" if the second character
doesn't occur again.
Examples
allAboutStrings("LASA") ➞ [4, "L", "A", "AS", "@ index 3"]
allAboutStrings("Computer") ➞ [8, "C", "r", "pu", "not found"]
allAboutStrings("Science") ➞ [7, "S", "e", "e", "@ index 5"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment