Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJohnathan Wenske
3,410 PointsPrograming Extra Credit Help
Hello! Under the Programming section of the Front End Development track there is an Extra Credit option at the bottom. I can't seem to figure out how to do it. Will someone help me. I only can do what the videos taught so I'm pretty useless right now.
Thank you guys!! Johnathan
Andrew West
3,245 PointsFizzBuzz is a popular/well known programming interview question.
I haven't taken that course yet so I'm not exactly sure what you need to know. Can you successfully print things to the log and read them yet? Do you know what the % (modulus) operator is? Have you used it before?
Johnathan Wenske
3,410 PointsI have no clue what the % (modular) operator is. The course before this extra credit does not mention it, so I'm not sure how I am supposed to complete it. I'm so lost.
Andrew West
3,245 PointsThe modulus operator returns the remainder of two numbers if you divided them.
5 / 2 = 2.5 could also be represented as 5 / 2 = 2 with a remainder of 1
The modulus operator returns that remainder 5 % 2 = 1
Here's a link to a one minute video about them
The reason this is key to the extra credit is because it's an easy way to tell if something is a multiple of a number.
IF (x % 3) == 0 then x is a multiple of 3
5 Answers
Andrew West
3,245 PointsIn regards to fizzbuzz I think you're on the right track now. Here's another hint that may be helpful
for (var x = 1; x <= 100; x++) {
if (x % 3 == 0) // Number is a multiple of 3
console.log("fizz");
if (x % 5 == 0) // Number is a multiple of 5
console.log("buzz");
}
Note: That is not the complete answer and still leaves a couple little issues for you to fix, but hopefully it puts you on the right track. Let me know if you guys need more help.
Edit: Replaced int with var because people wanted JavaScript
James Barnett
39,199 PointsThat is not the complete answer and still leaves a couple little issues for you to fix, but hopefully it puts you on the right track
For one it's not valid JavaScript.
Andrew West
3,245 PointsChanging it to JavaScript should be fairly simple. Their issue is the logic, not the syntax.
Chris Shaw
26,676 PointsTo make it work in JavaScript you just need to change int
to var
as JavaScript has no such thing as variable type casting.
James Barnett
39,199 PointsThe code challenge is in JavaScript. Here on Treehouse we try not to point newbies to dead ends.
So in general, please try a code challenge yourself before telling someone how to "fix" their an issue with their code.
Andrew West
3,245 PointsFrom what I understand the extra credit activities do not have videos attached and cannot be clicked on. They are simply suggestions for extra things to try on the side to learn more.
It would probably be good if they gave the extra credit sections special styling/formatting so they don't look like things to click on anymore.
Chris Shaw
26,676 PointsHi Johnathan,
Extra credit isn't something you earn points from, it's simply a way for you to test the skills you've learned so far and accomplish the set task by the teacher, if you want to share what you've done simply create a post on the forum, tagged in the correct category and then mention the teachers name in your post.
If you have a workspace link that you want to share post that too.
Hope that helps =)
James Barnett
39,199 PointsIf you have a workspace link that you want to share post that too.
Last I heard Treehouse Workspace links only work when the student they belong to is logged into the Treehouse.
Chris Shaw
26,676 PointsI just gave it a whirl and I was able to load a static environment without been logged in, below is a link to it =)
James Barnett
39,199 PointsI just gave it a whirl and I was able to load a static environment without been logged in, below is a link to it
If your account was recently logged into Treehouse then the Workspace instance was still live. Now 4 hours later according to the post time stamp, that link is dead.
Chris Shaw
26,676 PointsYeah, I closed it by mistake at work but it does work, I've opened it again for the next 6 hours.
James Barnett
39,199 PointsYeah, I closed it by mistake at work but it does work, I've opened it again for the next 6 hours.
Yep, as long as the window is open it the Workspace is accessible.
Chris Shaw
26,676 PointsWell James, I feel like an idiot because it only just occurred to me what you were trying to tell me, work really did a number on my brain today.
Lori Brandimarte
10,848 PointsI feel ya Johnathan. I am having the same issue. The problem is not understanding what the videos were about, the problem is that they did not hint to how to write the code to get the results. The closest I have gotten is to make it count backwards (which the Extra Credit sounds like they want it to go from 1 - 100, but the video only showed me how to stop the loop going backwards, so...). But it gives the numbers 4 times as the results.
I used some if/else statements like:
if (x%3==0){ console.log("fizz"); }
Don't know if that will help you...
If you find something more out, please share
=)
kloeferriman
3,171 PointsHere's what I did, although using only what the teacher had covered up until the extra credit assignment... so that means no ==, elseif, etc.
for (var number = 1; number < 101; number = number + 1) {
if(number%3){
if(number%5) {
console.log(number);
}
else {
console.log("buzz");
}
}
else {
if(number%5) {
console.log("fizz");
}
else {
console.log("fizzbuzz");
}
}
}
I'm open to criticisms :) Thanks!
Johnathan Wenske
3,410 PointsJohnathan Wenske
3,410 PointsYeah I wish there was something to the extra credit... But here is the one I am talking about, can anyone help me figure it out????
Extra Credit Fizz Buzz
Write a program that loops through the numbers 1 through 100. Each number should be printed to the console, using console.log(). However, if the number is a multiple of 3, don't print the number, instead print the word "fizz". If the number is a multiple of 5, print "buzz" instead of the number. If it is a multiple of 3 and a multiple of 5, print "fizzbuzz" instead of the number.
Hint. Use loops and if/else statments. In javascript the % is the modulo, or remainder operator. a % b evaluates to the remainder of a divided by b. 11 % 3 is equal to 2.