Skip to content

Instantly share code, notes, and snippets.

@david-pm
Created May 27, 2015 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save david-pm/3c84246b60a4da5c41be to your computer and use it in GitHub Desktop.
Save david-pm/3c84246b60a4da5c41be to your computer and use it in GitHub Desktop.
Interview Question
Question 1
Write a JavaScript snippet 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).
Question 2
Listen for an event on the unordered list in the provided html that uses event propagation correctly. On click, each button should log its inner html to the console.
Use the following html:
<!DOCTYPE html>
<html>
<body>
<ul id="grid">
<li><button>One</button></li>
<li><button>Two</button></li>
<li><button>Three</button></li>
<li><button>Four</button></li>
<li><button>Five</button></li>
<li><button>Six</button></li>
</ul>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment