Last active
August 10, 2017 02:58
-
-
Save jamessergeant/d34ba71b9189a8159456fd3deab62466 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Cat carousel | |
$(function() { | |
$('.thumbnail img').click(function(event) { | |
$('.hero img').attr('src',$(this).attr('src')); | |
}) | |
}); | |
// Fizzbuzz (should probably break down to separate functions as in reference solution) | |
function fizzBuzz(num) { | |
var fizzBuzz = []; | |
for (i=0;i<num;i++) { | |
if (!(i%3) && !(i%5)) fizzBuzz.push('fizzbuzz'); | |
if ( (i%3) && !(i%5)) fizzBuzz.push('buzz'); | |
if (!(i%3) && (i%5)) fizzBuzz.push('fizz'); | |
if ( (i%3) && (i%5)) fizzBuzz.push(i); | |
} | |
return fizzBuzz; | |
} | |
$(function() { | |
$('#number-chooser').submit(function(event) { | |
event.preventDefault(); | |
$('.js-results').empty(); | |
fizzBuzz($('input#number-choice').val()).forEach(function(fb) { | |
var div = $('<div class="fizz-buzz-item"><span>' + fb + '</span></div>'); | |
if (typeof fb === 'string') div.addClass(fb) | |
$('.js-results').append(div) | |
}) | |
}); | |
}); | |
// Lightbulb toggle | |
$(function() { | |
$('.js-lightbulb').click(function(event) { | |
$('.js-lightbulb').removeClass('bulb-on'); | |
$(this).addClass('bulb-on'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment