← Back to challenges

Changing Mixed Types

JavaScriptHardarraysconditions

Instructions

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, false]

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

changeTypes([false, "false", "true"]) ➞ [true, "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!
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Split Item Codes