Advertisement
Guest User

Untitled

a guest
Oct 17th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. //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
  2.  
  3.  
  4.  
  5. //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.
  6.  
  7.  
  8.  
  9. var numberBank=0;//this creates a new variable, names the variable "numberBank", and sets it equal to 0
  10.  
  11. 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"
  12.  
  13. 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..."
  14. numberBank += testNumber;//...then i will add that number to my number bank
  15. }
  16. }
  17. numberBank //asks your computer for the value of numberBank
  18.  
  19. -open chrome, go to "about:blank". You should see a blank page
  20.  
  21. -press command+opt+J, this should open up the console on the right side of the page
  22.  
  23.  
  24. -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