Hello all…this may sound like a silly question, so forgive me, but I wanted to reverse the Arrow Function in the example code for the Arrow Function - [I can workout the actual task but can’t solve *how it might* have looked before]
Hi…thanks for your reply, I’m not too sure what you mean unless you are referring to the if statement having " "…instead of saying name == undefined? [as mentioned in the previous reply I didn’t realise you could use ‘undefined’ as a condition].
The second part I presume would be:
const sum = function(a, b) {
"use strict";
return a + b;
};
I really appreciate your help…and sorry if I’m a bit slow on the uptake. I really am only a couple months into this and trying to cram it all in…so maybe missing certain elements.
Ok…wow…I feel really good after this now. Like I said I’ve been journeying with JavaScript [programming in general] for about a month - and i’ve been trying to get as much as possible into my head. It’s a steep learning curve and quite lonely learning on your own. But replies like yours really go along way for the confidence. Thank you my friend.
I’m happy to help. The curiosity to ask questions like “How do I try to add default parameters for non Arrow Functions?” will definitely help you on your journey : )
I asked you how to translate an arrow function to a regular one because It seemed to me you were misunderstanding default parameters, which is what the lesson is all about. If I wanted to translate the greeting arrow function to a regular one, I don’t need to have a condition in my regular function, because there isn’t one in your arrow function to begin with.
Although your greeting function using the function keyword is valid syntax, when one says regular function what’s usually expected is something like this:
function sum (a,b) {
return a + b:
}
And it’s a good thing that you take the time to ask questions like that by the way.
Ah right I get you…thanks. Makes sense. My problem being at this beginners level is i’m taking things very literally. I’m finding it a bit fuzzy trying to be lateral.
Like seeing your answer makes perfect sense…and I’m saying to myself ‘why didn’t I see as simply ‘function sum’ when writing it down’. It will come with time. Thanks for taking the time to help me though. Appreciate it.
M