# Will we meet something similer to this challenge i found on internet?

here is the challenge i found on another website that i think is a mind twister, i wonder if we gonna meet something similer in our coding careers:

“This time we want to write calculations using functions and get the results. Let’s have a look at some examples:”

``````seven(times(five())); // must return 35
four(plus(nine())); // must return 13
eight(minus(three())); // must return 5
six(dividedBy(two())); // must return 3
``````

will we have to call functions inside another function’s call which is inside another function’s call in our futur jobs as programmers? and how the heck is the challenge above possible? i mean the only way it’s possible is if the operator function is the one outer of the 2 calls which return numbers and they should be seperated by a comma, that’s how i imagined it, but call inside call inside a call is unclear on how to do it.
thank you.

Two topics:

• callback functions

Learn them and you should be good.

are these topics included in the fcc?

i can see callback functions but can’t see function overloading in this challenge. can anybody tell if this is covered in fcc so i can put it to rest.

[quote=“zak, post:1, topic:496003”]

will we have to call functions inside another function’s call which is inside another function’s call in our futur jobs as programmers?

Calling a function inside another function’s call list is no big deal.

What is going on there is some pretty sophisticated function currying. Would you see that on a job interview? I don’t know - I’ve never seen anything like that, getting that deep into the nitty gritty of how the language works. I’m used to seeing more basic algorithm stuff. I don’t know, you might see something like this if it were some big position or on a take home thing.

But you will learn the basic skills here. If you want to go deeper, books like the You Don’t
Know JS series and especially JavaScript Allongé go into this kind of stuff.

But you have to learn the basics first. I would not even look at them or the above problem until you’ve finished the JS section.

4 Likes

Yes, I mean at a base level that’s basically what you’ll be doing with most programming.

This is a toy challenge, but it’s a good one. As @kevinSmith says, you [probably] wouldn’t do literally what the challenge is asking you to do, but many systems work like this. React is a very good example of something that works on function composition, which is what this is. How React builds a tree of components is almost identical to this (it does some other fancy stuff, but at core).

It isn’t actually a hugely complicated thing, though it is just much more complicated in JS than in some other languages. I’d definitely try to do it, but you’re likely to need to look up quite a lot of things. It’s lambda calculus, essentially. And it’s pretty much purely functional programming

2 Likes

But really, the only thing beyond basic function use that I see is a little bit of currying. Actually, that may not actually be currying, but simply returning a function.

All this is covered in FCC.

There is also a little bit of “clever trickery” going on here, the kind that you get a sense for after doing a lot of algorithms and these kinds of problems. I’m not sure that you learn much useful in doing problems like this, except that you stretch your understanding of how functions work.

But if you’re just learning, stop worrying about things like this. Just learn to code. You can worry about things like this later.

3 Likes

I would also add that FCC is not a comprehensive course and is not meant to be. It gives you a solid foundation in web development. Will FCC make you an amazing JS coder that easily handles JS “gotcha” problems like this? No. But it will give you a solid foundation on which you can build if you want to explore things like this.

You don’t do into an algebra class asking if it will teach you how to solve calculus problems. No. But it will get you on the path.

1 Like

``````seven() vs seven(plus(seven()))
``````

looks like a good candidate to me.
Please correct me if I got it wrong.

edit:
Ok, currying may be a better option here, I stand corrected. : )

It’s not a matter of good candidate or not. Assuming this is JS, there is no function overloading in JS. I would just call this an optional parameter. I guess you could kind of call it function pseudo-micro-overloading, but I think most would expect a completely different function definition based on different parameter schema. This is just an optional parameter.

At least, that’s how I see it.

1 Like

I have a memory of completing that challenge and my coding skills are largly result of my FCC experience, so it is completely possible to solve the challnge after spending time on the FCC, altho it would be hard to pin-point specific lessons which can grealy assist you in the task. The thing is, workign with functions, their arguments, callbacks, is not an easy topic to learn and it takes lot of practice to become comfortable with. This challenge is not to be underestimated, but its also not one to require too complex logic or tools to complete. There are some more basic approaches which can help you. First of all, always check functions as an equation which can return a value. `seven()`, would return one value, `seven(5)` would return another value, `seven('+5')` another and `seven(addFive())` something else(replace `addFive()` with the value its going to return, so you know how the argument to `seven()` would look like). It strongly depends on the logic you imply to them. Conditional return values are common. Return one thing if you have one argument, return something completely different if there is another argument, or there is no argument at all. Here comes also your ability to work with function arguments.
Small tip. Functions can also return functions. Then those functions can be used as an argument, a callback.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.