Fat Arrows and This
Alrighty, without giving me the answer, let me know A) this question makes sense to you and B) if this is something I should care about. I'm stumped.

154 Replies
fat-arrow? who calls them that ?
this course apparently, threw me off too
oh, apparently the solution is to change it from an arrow function back to a regular function
wtf is the point
showing that function expressions bind
this
and not arrow functionsgotcha.
jeez being old is rough
everybody
I odn't believe you
Isn't the nomenclature 'anonymous functions'?
No this is an anonymous function:
oooo
Arrow functions are called that in the spec : https://tc39.es/ecma262/multipage/ecmascript-language-functions-and-classes.html#sec-arrow-function-definitions
ECMAScript® 2026 Language Specification
Introduction
This Ecma Standard defines the ECMAScript 2026 Language. It is the seventeenth edition of the ECMAScript Language Specification. Since publication of the first edition in 1997, ECMAScript has grown to be one of the world's most widely used general-purpose programming languages. It
anonynous function expression
Well yes... But it defines an anonymous function so... I'm also correct
it is
and it is very correct
This is an anonymous function
ha ha ha
no, that's a function called
anonymous

I would never have guessed the correct answer was
Iirc with no knowledge of OOP I think
super
refers to the parent object, so it would refer to Sender
Yeah I get it now, I completely missed that underneath the initial bit of code, there was
Yea makes sense, parent class has all the methods and then child class just spits out the parent method return with some additional output attached
so return
${super.formatMessage(message)} [SMS]
; is just using return To: ${this.recipient}, Message: ${message}
; and uhh.. adding some.yea
makes sense
useful, too
And then you'd make another one for
[Email]
tooyeah got that one, phew, classes done (short, hmm)

the fuck is this?

that's easy
the floats are throwing me off massively. Especailly when the intro was "hey here's a loop that increments by 1 each time" xD
in fact, even the next assignment is seriously messing with me
dude, this is super easy:
count + (count / 100) - 0.01
oh, wait, no, it's incrementing
yeah, that's basically this then:
1 + (index / 100)
, for each loop
but there's a formule to calculate this without a loop
https://stackoverflow.com/a/50566815
maybe try the first answer instead
I had no idea how to get that totalCost sum though, tbh.
I would've never guessed += 1.0 (i * 0.01)
maybe it's just a mental block I have or something but the entire section I Struggled with and had so much help to get right
this is actually basic math, not a language thing
you can do
numMessages + (((numMessages - 1) * numMessages) / 200)
💀
wtf
which is what's in the link i've sent, but applied to that exercise
I'm either uneducated or the lessons aren't clear, and by the number of people completing them, it's not the lessons
I think you could just do something like this too: (thanks Epic for the math I was completely blanking on how to get the 0.01 lmao)
i would try something with reduce
that's what it is for
Always forget about reduce
but that is to loop over the messages, by the way
if all you get is the number of messages, your solution doesn't work
unless you create and fill an array of elements
Ahhh thought there was a messages array
don't worry we're passed that one, I'm now having to check if a number is prime but I have to use continue and break ^^
i don't know if there is
I think same way would work though
if you make an array and fill it, it works
You could just do
numMessages.forEach((_, index) => {});
but yea reduce is definitely betternumMessages would be a number
Or is numMessage an int
Ohh
I'm dumb
Hehe
left is my attempt, right is the answer 😄

does it specify what should happen to 1?
yeah 1 can't be printed
This course doesn't agree with me anymore lol, I can't get my mental around the wording, I'd be better off just doing bloody codewars at this rate
that answer is so terrible: it lacks memoization
but js doesn't have good options for that
it works, but it's so unoptimal
I oppose you :
forgot those thingies exist now
there is sadly no clean way to get an infinite iterator :/
What in the Minecraft is that code
this creates and infinite iterator that simply enumerates positive integers :
then we
.take()
the first numMessages
and .reduce()
them into the index / 100
then add the constant 1
for each (i.e. add the number of messages)
technically, it should be possible to find the canonical form of the mathematical suite and have the result without using any iterationlike this, but better optimized
that code is a bit shoddy
iterators are fun
they are
it is rare for me to use those, but they are cool
this function would give you the right answer too...
no iteration needed
it's basically what i wrote, but less bad
oh, yeah, had not understood what you meant by what you sent, but yeah
math is neat
it is really neat
i suck at it, but it is neat
a while ago, i found an algorithm that lets you calculate a running average
imagine you have 5467372 star ratings
instead of recalculating it all for the 5467373rd one, you run a formula that just spits out the new average
i remember you just need the current count, the next count, the current average and the new value
Wouldn't you need to subtract
numMessages/100
from the product of this to get the correct result
Because the dynamic charge is 0 at first message and begins from second message
ah nevermind it works because - instead of plusNone of ^ made any sense 😂
the formula to calculate the sum of all numbers from 0 to n requires you to divide by 2
your challenge requires the division by 100, to get 0.00, 0.01, 0.02 ...
so, if you divide 1 by 200, you get 0.005
why 200? because you divide by 2 then 100, which is the same as dividing by 200
the exact formula for summing all numbers from 0 to n looks like this btw
n(n+1)/2
where n is the numbers you want to count up to.
for example I want the sum of all numbers from 0 to 3 so 3*(3+1)/2
result is 6
.that is a different version of the formula we used, but it works the same
I was giving the basic formula yeah.
Oh, this is like a purely math assignment which is why I failed lol
Well you might encounter problems like these on a job, this was a pretty basic problem
no, this is the "no loop" solution
you can use a loop, as explained before
The loop solution from before works, but if you had to handle requests for a million messages sent it would take a while because it's O(n). The math solution is O(1), no matter the number of messages to send it'll take the same amount of time to compute. But if all you need is the result and you don't care about perf (like is the case in your assignment) both are perfectly valid.
yup, but luckly it only slows down linearly and not exponentially
So is the assignment a common occurrence? If so im gonna need to study this more, specifically.
no
it's just basic math
it isnt common, but it isnt obscure
it's just something to make the mind work
I think it's another of those googleable thing. I didn't know the formula myself but I did recognise the pattern and just googled formula for summation of a sequence of numbers
Then went from there
and this simple exercise shows you have some problems with extracting information from exercises
same
but the problem here is that he couldnt understand what the exercise was about
it wasnt super clear, i will admit it, but it isnt complicated
Yeah true
If you can't understand then you can't google
exactly
Yeah, ya need to work on that CDL, most of what a developer does is turn shitty explanations from the client and turn it into specs before implementing them. It's important to be able to find patterns in the shitty explanations to have simple specs and simple code in the end
and this one is an easier one
imagine someone who wants a booking system that can light a cigar while baking a pie
you have to extract what matters - the booking system
Basic math? 💀 basic math to me is 2*2
That’s pretty much held me back for 3 years lol, I’ve no idea how to improve it, or if I can. Obviously if I can’t then there’s no point continuing.
That's honestly part of most jobs outside of factory work...as to how to get better at it I have no idea
yes, basic math
if you see, the price goes from 1.00 to 1.01 to 1.02 ...
so, the last digit is like the index in an array, and the first is just a constant
but since it is 2 decimal places to the right, you divide by 100
but you have to add it all together
so a loop that does
total += 1 + (i / 100)
but for some people, it is easier to just multiply by 0.01 - which is the same as dividing by 100, as you learned about it at schoolOh ok
Fair enough
this is why we are saying it is basic math
oh, and at the end you just add everything and that's the cost of sending n messages
Gotcha
My diet sucks and is heavily caffeinated, I blame this for the reason im a dumbass lately lol. Let’s try lower the caffeine for a bit 👀
yeah, and sleep better
I get 8 hours of sleep a night, I just rely on sugar snacks to get me through the day lately. 3-4 coffees a day, few chocolate bars/sweet bars and 1-3 Coke Zero cans
It’s super bad lol
that is not just super bad: that is horrible
that's way too much caffeine
It’s copious amounts of sugar/glucose
Probably the leading cause to my coding consistency lol, chasing sugar and dopamine (chocolate and gaming)
dude, i eat really unhealthily
but i still include fruit and vegetables in my diet
I have veggies for dinner but that’s about it
I’ll change 😤
you should
i don't eat nearly enough fruit or veggies but going to the grocery store and trying out new stuff is always fun, maybe you'll find something you really like
how in the fuck am I meant to know the solution to this was to start by assigning a variable the value of -1
HUH.

"if not found, just return -1"
That confused me a lot, I initially put return “-1” 😂😂😂😂😂
that's the error condition
that's your starting state
you start in the unhappy path
Ya need to learn to break down problems into smaller parts. That's what bites you every time.
^ exactly
Yeah most likely. I breezed through up until this one and even in this one I had everything except the -1
the -1 was very explicit there
Yeah though I read that as literally return -1, so I wrote “-1” 😎
but that is what you have to do ... and the rest of the stuff
😫
what's so confusing about the -1?
My brain cannot comprehend the -1 lmao and I’m not at my pc to look at the solution anymore
Trusty mobile to the rescue

Yeah maybe I am just being confused as the solution does I; -1, I tried doing return “-1” lol
remember that
findIndex
is a thing : logs.findIndex(log => log.includes(slug));
Ah… i tried indexOf lol
I can't find a a way to golf it more... :/
so there's Map, teh array method, and then there's... Map...?
iterators
.map
<-- the array method
Map
<-- allows you to make a map between anything to anythingyeah seems pretty cool
(there's code behind this code, you just don't see it)
why do you make a new map ?
part of the assignment
create a copy of the input, add phoneNumber and name as key:value pairs, return the new Map
so I created a copy of phoneBook, added phoneNumber => name, returned newPhonebook
hum... ok...
you can do that to make things easier to read
remember that what goes in MUST BE the same type as well, or you won't get the value out
good to know, looks cleaner also
promises still fucking me up a year after initially learning them

try to break down the assignment before going in
I did, I managed it 😄
maybe long winded code wise, but it passed the test cases
event loops can get in the bin
What are you talking about
oh nothing, this is jsut my thread of venting my way through bootdev apparently, lol
Did boot dev link that event loop video from js conf
Cause that would probably help a lot if they didn't
nope
JSConf
YouTube
What the heck is the event loop anyway? | Philip Roberts | JSConf EU
JavaScript programmers like to use words like, “event-loop”, “non-blocking”, “callback”, “asynchronous”, “single-threaded” and “concurrency”.
We say things like “don’t block the event loop”, “make sure your code runs at 60 frames-per-second”, “well of course, it won’t work, that function is an asynchronous ...
Ohhh I remember this video!
So they did link it?
nah I saw this years ago
I don't fully remember the context though so i'll watch it again
Ah kk. It's probably the best one on YouTube, microtask queue explanation is missing but the all other concepts are similar enough
https://www.youtube.com/watch?v=eiC58R16hb8 <-- here's another video, if you want
Lydia Hallie
YouTube
JavaScript Visualized - Event Loop, Web APIs, (Micro)task Queue
Learn how the browser event loop, task queue, microtask queue, and Web APIs work together to enable non-blocking, asynchronous JavaScript.
- https://www.patreon.com/LydiaHallie
- https://buymeacoffee.com/lydiahallie
- https://twitter.com/lydiahallie
- https://www.linkedin.com/in/lydia-hallie/
- https://instagram.com/theavocoder
Timestamps:
0:...
I'm constantly getting messed up with setTimeout, I think it's jus the way it looks more than anything.
So this is runnign setTimeout on "Hi I'm async!", even though it's 0, it'll run AFTER "Job started"?
and then it'll call workOnJob()
oh actually, the damn course explains it lmao
it runs after 10ms

or 2ms
depends on the browser
yeah but with the others being immediate, it's a long enough delay (even if it shows 0)to make it go last in the queue
setting it to 0 won't make it run any earlier
i will tell you a secret
this loop thingy? it doesn't matter
you almost never will think about it or need to care about it
fair
just trying to get this bit done so I can move on lol, I'm a completionist, I can't leave the section empty
but it's testing my darn patience that's for sure
aight I'm through it. Runtimes and Modules left then I'm onto Typescript, finally.
good, you're moving forward
fuck sake, 'bout time

'ere we go

this is gonna take some getting used to!
why is there a squiggly on a perfectly valid code ?!
WHY ?!
Not sure tbh, it went after i filled the empty “” with text
okay someone explains this to me lol. the challenge is to create the type SupportResponse and to use it.. I managed to get it to work with an arrow function and when asking the helper (ai) to create it using a normal function, it doesn't even use SupportResponse...?

Is it TS being smart and matching SupportResponse to the function? "hey this is taking name as a string and returning a string, it must be SupportResponse"
typescript matches types by their shapes, not by their names. so yes it's "hey it look the same, must be the same thing"
callable types (functions) are basically only ever used for callback tho
if your training stuff didn't go over how typescript works you might want to look at the typescript into on their doc : https://www.typescriptlang.org/docs/handbook/intro.html
Handbook - The TypeScript Handbook
Your first step to learn TypeScript