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.
Thanks!!
You need to return the answer, not print it.
https://docs.codewars.com/training/training-example
Anyone had this problem?
Unexpected exception raised.
Traceback (most recent call last):
File "/workspace/default/.venv/lib/python3.11/site-packages/codewars_test/test_framework.py", line 112, in wrapper
func()
File "/workspace/default/tests.py", line 10, in basic_test_cases
test.assert_approx_equals(find_average([1, 2]), 1.5, margin=1e-3, message="Failed for [1, 2]")
File "/workspace/default/.venv/lib/python3.11/site-packages/codewars_test/test_framework.py", line 85, in assert_approx_equals
div = max(abs(actual), abs(expected), 1)
^^^^^^^^^^^
TypeError: bad operand type for abs(): 'NoneType'
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
me to
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Hi begginner here, how does it works? I mean, I wrote the same thinks but how could it works on the negative numbers? Because the positine ones get to negatives thanks to * -1, I get it; but does it work for the negatives one? Maybe it's the "=" that's I don't understand here. Sorry for my bad english, hope someone will understand my question.
Oh I never saw that one, thanks you for reply !
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_accessHi! Beginner here, I thought [] was for the array only. Why, can we use [] for the string "name" here? Sorry for my bad english.
I LOVE IT
This comment is hidden because it contains spoiler information about the solution
Loading more items...