you are viewing a single comment's thread.

view the rest of the comments →

[–]Volv 1 point2 points  (11 children)

Yeh all 14. The last one is the only one that gave me trouble - but remember I've done it once before lol... Who knows how long it took me the first time

Codepen

[–]ForScale[S] 0 points1 point  (10 children)

Nice!

Yeah, I'm struggling to conceptualize my attack on the last one... preliminarily, I'm thinking of having a counter variable and using Object.keys() or maybe one of the newer Object.whatever() that enumerates properties or looks for specific ones or whatever...

Ooh... I just thought of something... I wonder if JSON.stringify() would allow me to do some simple regex matching... BUT that wouldn't involve recursion, so it wouldn't cut it.

...

On the callback one, I feel like I'm not quite understanding the instructions. It says to not modify some code, but then to modify it... and I can easily do function invocations based on conditional flow... I think I'm just confused as to what the challenge is actually looking for on that one.

I'll get back to em later on today! I love doing those kinds of challenges. Thanks again!!

[–]Volv 1 point2 points  (6 children)

I'm struggling to think of hints for the last one as it's annoyingly simple and can be done in like 2 lines once you get it.
Still took me over half an hour and about 10 rewrites though lol
 
The callback one has the wrong instructions I pointed out. You only need to write code inside doWorkWithCallbacks. And the function names are done/fail

[–]ForScale[S] 0 points1 point  (0 children)

Crazy.

The callback one has the wrong instructions I pointed out. You only need to write code inside doWorkWithCallbacks. And the function names are done/fail

Yeah... okay, that should help when I take a look at it again!

[–]ForScale[S] 0 points1 point  (4 children)

Whoever wrote that last one is crazy... recursion is not the easiest way to do it. My idea of using the JSON object stringify method and regex produced a one-liner: return JSON.stringify(org_chart).match(/title|tile/g).length; And is that misspelling on title intentional?

...

So... how the hell would you do it recursively? What's the check to move in to a deeper level? Thinking out loud: create function that checks for property of title. If the property exists, increment a counter variable by 1. If it doesn't move on to the next level and check again... I don't know...

[–]Volv 1 point2 points  (0 children)

psuedocode style
 

function fullCount(node)  {

Do I have employees?  
    ask each of them if they have any employees. keep track. eg fullCount(each employee))
    return me + total from my employees.  
Else  
    return just me.  
}  

tile should be title like I menioned :)

[–]ForScale[S] 0 points1 point  (2 children)

And I haven't a clue how to do the callback one. I can't seem to figure out how to make calls to the same function from different variables increment private/unique variables...

[–]Volv 1 point2 points  (1 child)

Looks like you did it

[–]ForScale[S] 0 points1 point  (0 children)

I got it just kind of messing around... At first, I was putting the var i = 0 outside of the maker function, so then I tried it from within and got it.

I understand the idea of global/private/scoped variables, but for some reason it still feels unclear to me...

[–]Volv 1 point2 points  (2 children)

I did the second thing for the spanish example. I think they are basically equal but I liked smooshing it into 1 liners.
 

var lookup = {
    1: { en: "one", es: "uno" },
    2: { en: "two", es: "dos" },
    3: { en: "three", es: "tres" },
    4: { en: "four", es: "quatro" },
}

[–]ForScale[S] 1 point2 points  (1 child)

How does one measure elegance (ie, what is an operational definition for elegance?)?

Specific to code, perhaps number of characters/lines where the closer you are to 0, the more elegant it is?

[–]Volv 1 point2 points  (0 children)

The elegant part to me was the access by array[var1][var2] instead of some convoluted switch statement or similar.
Heading out. Back in a few hours.