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.
See: https://docs.codewars.com/training/troubleshooting#print-input
array || []
evaluates toarray
whenarray
is a truthy value and otherwise evaluates to an empty array.So,
array = array || []
will setarray
equal to an empty array if it does not already refer to an object.I think you've got things backwards. Your code returns true for 47 but should return false.
If the goal of the function is to return a sorted array, not returning one in some cases seems counter-productive to me.
https://docs.codewars.com/training/troubleshooting#error-messages-and-printing-your-inputoutput
This comment is hidden because it contains spoiler information about the solution
How many times do each of those numbers that 2 is a factor of occur?
s += tmp
is short fors = s + tmp
. So,s + tmp
is literally saved tos
for every iteration of the loop. This expression is not "inside a function call". The result of the evaluated expression (s
) is used as an argument to the function.Any code of the form:
can be rewritten as
Take a close look at your alphabet.