Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //anytime you ever put two slashes at the beginning of a line, like i just did- this means that anything after the "//" won't be recognized as code. Like, programmers just use this to leave notes for each other inside their code. I'mma use it to explain each line one by one
- //Preface: what this code technically does, is checking every number from 1-999, and if that number is divisible by either 3 or 5, it adds it to my number bank. Once it finishes checking all 999 numbers, it tells you the value of the number bank.
- var numberBank=0;//this creates a new variable, names the variable "numberBank", and sets it equal to 0
- for(var testNumber=1; testNumber<1000; testNumber++){//this line means "starting from 1, until 1000, I'll run this code below, and then go to the next number"
- if(testNumber%3==0 || testNumber%5==0){//if the number I'm testing is evenly divisible by 3, OR is evenly divisible by 5, then i will..."
- numberBank += testNumber;//...then i will add that number to my number bank
- }
- }
- numberBank //asks your computer for the value of numberBank
- -open chrome, go to "about:blank". You should see a blank page
- -press command+opt+J, this should open up the console on the right side of the page
- -copy and paste this code into the console, press enter. Should give you a number/answer
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement