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.
Because you have the initalization of your arr variable inside your loop so it continues to get reset.:)
According to the kata ranking system here is a description of 8 kyu: Imgur
Seems to fit "Basic variable assignment" and "Basic math operations"
You should respect Kyu rang 8.
This comment is hidden because it contains spoiler information about the solution
Test cases check if your method return proper value, so you should add proper keyword :)
I think where you're going wrong is that your
for
loop capsi
byn.length
rather than the value ofn
.Also your short-if should probably have a false condition with
:
last[last.length-1]
returnsundefined
becauselast
is the name of the function, not of an argument.list
may be the unique argument if there's only one OR the 1st arg. if there're more than one.So, before returning "last of list" you should know if there's only 1 arg. or not.
typeof list
return "object" if list is an array; you may uselist instanceof Array
instead;typeof list=="array"||"string"
returns "string" so it's always true andarguments[arguments.length-1]
is never returnedbtw you test typeof
list
to choice what you return but beware thatlist
is only the name of 1st argument (if there're more than one) and that this 1st argument may be a string or an array too.eg:
keep on little padawan
Your solution is a bit too complicated, in fact you may access to last argument simply with :
arguments[arguments.length-1]
as you do with your list.