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 in my opinion it is readable, no more. You shouldn't attribute your complexes.
Your first take was: "the sum first and then the multiplication..?"
Ok, "2+2*2 = 8" guys, chill
Let these people learn math base rules first, not rust.
It's ridiculous to make such mistakes.
––––––––––––––––
Edited: But now i see u edited and mean clarity way, ok, i agree with that, but strange thing yet
It definetly can work without the braces due to math rules, but sometimes a small element like this gives tons of clarity.
(6 * 3) + 2 = 20 (I bet close to 95% of people solving this will get the right answer)
Comparing to:
6 * 3 + 2 = 20 | 30 (Here there will be confused people doing the sum first and then the multiplication)
braces..? why
https://stackoverflow.com/questions/5971645/what-is-the-double-tilde-operator-in-javascript
Nevermind, I didn't see the other replies.
I don't get the part where c is a boolean but also remembers carrying the number into the next loop.
Why is that?
Edit: got it.
If you add a variable with true to a number the truth equals to one.
So:
var a = 5
andvar b = true
becomes witha + b
a solid6
.Didn't know that.
Love your aproach!
I think it'd be worth adding another variable name to make the code a little more clear. It confused me that you were using the c variable for summing and carrying over a digit. For example, you could say var sum = ~~a.pop() + b.pop() + c instead of c += ~~a.pop() + ~~b.pop(). And then say res = sum % 10 + res
It looks like we are expected to include a .equals method as well even though it is not specified.
What is doing the
~~a
,~~b
in javascript can't find any documentation ? Thanks!I got some issues with the
a.add(...).equals is not defined,
i think there are some issues with the test case.This comment is hidden because it contains spoiler information about the solution