Write a function that accepts a string and returns the same string with alternate casing.
- Both versions map over each character without counting the number of characters.
- The cljs version doesn’t use the index to determine which function to apply.
- The cljs version will be simpler to extend, e.g. replace every third char with a space. (In the cljs case, we just add the function to the end of the
cycled vector. In js, we’d need to add another branch to our
- The cljs version gives us functions as first class, i.e. we can use the string functions as arguments. In js, we have
toUpperCasethat can only be applied to string instances. If we want to pass them as arguments, we have to wrap them as functions or perform some other workaround.