Counter (Closure - Day3) - Leetcode 2665 - JavaScript 30-Day Challenge

preview_player
Показать описание


leetcode 2665

#neetcode #leetcode #python
Рекомендации по теме
Комментарии
Автор

There is an difference between

count ++ vs ++ count

Count++ increment the value but only from the next line changes are applicable

++Count increment the value but the changes are applicable immediately.
Count = 5

Example
Return Count ++
Console.log(count)
// 5
// 6

return ++count
Console.log(count)

// 6
// 6

jayakumar
Автор

Javascript is a really weird lanuage, your explanation make things much more straight forward. Huge thanks.

sgtbujo
Автор

Day 3 of doing the 30-day challenge with neetcode!

vixguy
Автор

Please upload leet code data structures questions as well.

sharathkumar
Автор

Bookmarking this playlist for my next interview . Kudos to your hard work

MohdMonis-zfgj
Автор

You could have created an object and created an increment key and assign arrow function to it
And return the whole object counter

Return obj {
Increment: () =>{
Return ++ count
}



}

jayakumar
Автор

the account of yours is underestimated :0

mk-vgmx
Автор

bro you're amayzing! thanks a lot!!

abirkolin
Автор

solved this hours ago, here just for your explanation

hmryhud
Автор

we have already assigned init to count in the first line: let count = init;
why are we doing count = init again in the reset function body? When I try to return count directly, it outputs wrong answer.

KyuriousBot
Автор

i think the problem in the description attached is a different one !

sagnikc
Автор

i am new to js
can anyone tell why do we use
increment: increment
dec.. : dec..
reset: reset

harshitpant
Автор

@2:59 "incremention" rears its ugly head again! again with the incra-mention!

EzraSchroeder