Changing Mixed Types

Published by Werdna in

Create a function that changes all the elements in an array as follows:

  • Add 1 to all even integers, nothing to odd integers.
  • Concatenates "!" to all strings and make the first letter of the word a capital letter.
  • Changes all boolean values to its opposite.

Examples

changeTypes(["a", 12, true]) ➞ ["A!", 13, 0]

changeTypes([13, "13", "12", "twelve"]) ➞ [13, "13!", "12!", "Twelve!"]

changeTypes([false, "false", "true"]) ➞ [1, "False!", "True!"]

Notes

  • There won't be any float values.
  • You won't get strings with both numbers and letters in them.
  • Although the task may be easy, try keeping your code as clean and as readable as possible!
  • false becomes 1 and true becomes 0
Watch a quick demo on how Edabit works.