FizzzBuzzz Problem PLS help


#1

Hallo, could someone help me pls?

I try to solve the FizzBuzz task.
FizzBuzz
Write a program that uses console.log to print all the numbers from 1 to 100,
with two exceptions. For numbers divisible by 3, print “Fizz” instead of the
number, and for numbers divisible by 5 (and not 3), print “Buzz” instead.
When you have that working, modify your program to print “FizzBuzz” for
numbers that are divisible by both 3 and 5 (and still print “Fizz” or “Buzz”
for numbers divisible by only one of those).
(This is actually an interview question that has been claimed to weed out
a significant percentage of programmer candidates. So if you solved it, your
labor market value just went up.)

I understand the solution but i have some problems witch i underlined with red color at the screenshot.

i % 3 == 0

  1. why is it “0”? It should be not " 0 " but some kind of term for a “whole number/integer” and not zero “0” in my opinion. (3 divided by 3 is 1 and not 0 “zero” i would say:))

else if(i % 5 == 0 && i % 3 !=0)

  1. what i dont realy understand is why its two times “=” equal sign and only one time “=” equal sine at the end (!=0).

Can someone pls help me and explain me in easy english?
Thx, and sorry for my not perfect english.


#2

Hi Pendejo,

Don’t worry your English is great. Hopefully, I can answer this clearly:

% is called modulus which is the remainder of a division not the division itself:
e.g. 3 / 3 (3 divided by 3) is 1
e.g. 3 % 3 (what is the remainder of 3 divided by 3) is 0
Here’s a good reference of operators and math:
https://www.w3schools.com/js/js_operators.asp
https://www.w3schools.com/js/js_arithmetic.asp

A single operator (above) is used to change or assign variables:
// creates a variable called ‘name’ and assign it a (string/text)value of ‘Pendejo’
e.g. name = “Pendejo”;
// creates a variable called ‘ageNextYear’ and assigns it a value of the age variable plus 1
e.g. ageNextYear = age + 1;

A double operator is used to compare or check something:
e.g. if (name == “Pendejo”) {
console.log(“Hello Pendejo)”;
}
else
console.log(“Who the hell are you?”);

Ivan’s course is absolutely fantastic but I think for people who are either new or a little rusty to coding, like I was, I’d suggest going through this free course: https://www.codecademy.com/learn/introduction-to-javascript

Hope that helps and feel free to ask anything else.


#3

THX a lot!!! now i understand it! THX again


#4

You’re welcome. Feel free to post anything else.