If after searching in Google, some questions are still troubling you with ‘Values, Types, and Operators’ section in the book, please post your questions below
RE exercise #2 of chapter two which is the FizzBuzz.
This was a great exercise example. However I didn’t understand some of the code logic of the solution n++ on the first line. Don’t understand the double ++ and wasn’t explained in chapter 1or 2. .
Also didn’t understand the reasoning behind the “+” before “=” in the following lines of code:
if (n % 3 == 0) output += “Fizz”;
if (n % 5 == 0) output += “Buzz”;
As a suggestion, it would have been quite helpful for raw/ brand new coders if the instructor would have done a post exercise solution explainer that would going into breaking down the logic behind each function and line within the answer to the problem.
Its a bit frustrating that I wasn’t even close to solving on my own by only reading chapter 1&2, but by trying to reverse engineer the exercises after looking at the solutions I do find myself learning more that way, but still unclear as to some of the logic. Even showing scenarios of what would happen if you didn’t include the right code will help understand its usage.
The n++ is the same that increase n with 1->n=n+1
The “+=” concatenates the previous value with the new. I mean:
gives as result a= ‘Hello’
In the exercise, it do like that because each time the output is reseting to null (output="")
Only in the case that “n” is divisible by 3 (it add “Fizz” to the “output” string) and 5 (it add “Buzz” to the “output” string also") It will shoy FizzBuzz as result to add the two strings one after the other.