# Need A Lot of Assistance From An Actual js Dev

**URL:** <https://forum.devtalk.com/t/need-a-lot-of-assistance-from-an-actual-js-dev/34041>\
**Category:** Frontend Questions/Help\
**Tags:** js\
**Created:** [25 December 2021 02:23 UTC](https://forum.devtalk.com/t/need-a-lot-of-assistance-from-an-actual-js-dev/34041 "2021-12-25T02:23:06Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![The\_Exile](https://forum.devtalk.com/letter_avatar_proxy/v4/letter/t/958977/32.png) [@The\_Exile](https://forum.devtalk.com/u/The_Exile)\
**Post date:** [25 December 2021 14:16 UTC](https://forum.devtalk.com/t/need-a-lot-of-assistance-from-an-actual-js-dev/34041/5 "2021-12-25T14:16:27Z")

</div>

> [@mindriot](#):
>
> The problem with your version is the sequence of conditions that are checked means the FizzBuzz case can never happen. I’ll leave it as an exercise to work out how to fix this based on the points above, if you are still struggling I can help further.

(BASHES HEAD AGAINST DESK.)

I know this… Why didn’t I notice… UGH. I guess I should have just stepped away and came back to it. Ugh… Now I feel REALLY dumb. The author doesn’t mention it in his book but, I remember it from other books I’ve read.

> [@mindriot](#):
>
> you are also correct that `n++` is a shorthand for `n = n + 1`.

What if I need to increment more than 1 at a time? Do I just add more + symbols? Or I just need to do the long form like n = n + 2?

> [@mindriot](#):
>
> The `+=` is another one of those short hands similar to `++`. It combines the plus and the assignment together so `output = output + "Fizz"` and `output += "Fizz"` are the same. Also `+` when used on numbers does addition, but when used on strings (like here) joins them together (concatenates).

I know about the arithmetic use and the concatenation use. But… The others…

output = output + “Fizz” to me makes perfect sense…

output += “Fizz”… That makes sense now that you’ve explained it. Wish the author explained it before using it. Lol.

> [@mindriot](#):
>
> To go a little bit deeper into this, many things in javascript are not true/false but are often “truthy”.

What? You lost me.

> [@mindriot](#):
>
> If you do a comparison with `===` or `!==` then it is strictly comparing true/false values but in most other cases if it has a value then it is interpreted as true and if it does not then it is interpreted as false.

I think I remember him mentioning this in the chapter I read.

The example I think he gave was something like this…

“dog” === “cat”  
and it evaluates to false since the strings aren’t identical and it’s looking for an exact match.

“dog” !== “cat”  
and it evaluates to true since they are the inverse of the previous example.

Did I remember that correctly?

> [@mindriot](#):
>
> 0 is also considered false, while a string with some letters in it `"hello"` is considered true and a number other than `0` is also considered true.

0 is true and false? You lost me again.

> [@mindriot](#):
>
> javascript also doesn’t care much about types of values and will in many cases try to force the type of a value into one that works.

The author mentioned this in the first chapter. So far it seems the info in the book is great it’s just the author’s examples that are causing confusion.

> [@mindriot](#):
>
> The result of evaluating `output || n ` is used as the input to the console log. A clearer way of writing this particular example would be something like:
> 
> ```auto
> if (output) {
> console.log(output);
> } else {
> console.log(n);
> }
> 
> ```

Yes! ok! That is much easier to understand and read. Kinda wish the author gave me that instead Lol.

> [@mindriot](#):
>
> Lets go through this authors loop with some comments…
> 
> ```auto
> for (let n = 1; n <= 100; n++) // starting at 1, run the block (from { to } ) for each number n up to and including 100
> { 
> // for this particular n
> let output = ""; // start with an empty output string
> if (n % 3 == 0) output += "Fizz"; // if this n is divisible by 3, join "Fizz" to the output string
> if (n % 5 == 0) output += "Buzz"; // if this n is divisible by 5, join "Buzz" to the output string
> console.log(output || n); // log the output if it isn't empty, log n if the output is empty
> } // move on to the next n
> 
> ```

Omg yes. COMMENTS! Why the author didn’t provide his example like that is beyond me.

> [@mindriot](#):
>
> `for (let n = 1; n <= 100; n++)`

Ok so anytime I am going to invoke a for loop I need to follow the following syntax…

for ( declare variable and assign a value ; ( Don’t really know what you would call this part ); Index Counter Increment. )

> [@mindriot](#):
>
> One thing of note beyond your questions here, unlike your version this author is using 2 independent `if`s.

In the author’s example there are no if’s, did he use some sort of shorthand method or something?

> [@mindriot](#):
>
> You aren’t the only one that feels that way.

Good to know I am not the only one. Lol. After I typed up my question I went to the ECMA’s website and downloaded the latest ECMAScript Language Specification and started reading the section on for loops. Lol.

Unfortunately, it seems they also have an issue with describing things in such a way that a non-engineer can actually understand what was written. Lol. I tried to read the syntax it provided but, it wasn’t very clear and they do not provide any examples so it’s difficult to understand what they are trying to say. I am sure if I read the spec from start to finish it would make sense but, right now, I just don’t have the time for that.

---

_[View the full topic](https://forum.devtalk.com/t/need-a-lot-of-assistance-from-an-actual-js-dev/34041)._
