Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
JohnnyDiabetes, you make a good point. If I made this today I'd do a few things differently, one of which would be to create a new array and return that.
Just a heads up:
Kata directions: "Do not mutate the input array/list." This solution mutates the input array.
This comment is hidden because it contains spoiler information about the solution
The *= is a multiplication assignment and can be read the same away as array[i] = array[i] * -1. It is a shorthand solution that often gets used when solving problems.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Multiplication_assignment
Hi! This is a shorter way of accessing the
.charAt()
method on a string. Take a look at the docs here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#character_access