3h in today on flatiron Academy’s bootcamp prep class. It has definitely felt like rough sailing since I dropped back into the learn.co platform. Today there were a bunch of sections that didn’t have full ide support so you had to fork them and push them manually. That wasn’t bad, but they seem to use terminology that confuses me. I.e. saying ‘you can do this in your browser’ doesn’t help me understand if I am supposed to download it and open that file up vs using the built-in IDE. Eventually it gets sorted out, but it slows things down by a ton and really takes me out of the groove.
Enough bitching. I did three main pieces of code today. I made the konami code in js.
const codes = [ "ArrowUp", "ArrowUp", "ArrowDown", "ArrowDown", "ArrowLeft", "ArrowRight", "ArrowLeft", "ArrowRight", "b", "a" ]; function init() { let count=0 const main = document.querySelector('body') main.addEventListener('keydown', function(event) { if (event.key === codes[count]){ count++; } else { count = 0 } if (count === codes.length){ alert("YOU DID IT!") count = 0 } }) }
I wrote some jquery selector functions
function paragraphSelector(){ return $('p') } function lastImageSelector(){ return $('img:last') } function ninjaBabySelector(){ return $('#baby-ninja') } function divSelector(){ return $('.pics') } function firstListItem(){ return $('ul li:first-child') }
and I worked on jquery event handlers
function getIt(){ $('p').on('click', function(){ alert('Hey!') }) } function frameIt(){ $('img').on('load', function(){ $(this).addClass( "tasty" ); }) } function pressIt(){ $('#typing').on('keydown', function(key){ if (key.which == 71){ alert('you pressed the g key.'); } }) } function submitIt(){ $('form').on('submit', function(){ alert("Your form is going to be submitted now.") }) } $(document).ready(function(){ getIt() frameIt() pressIt() submitIt() });
This has been my first bit of jQuery, so it is slow in the beginning. It’s a bit weird that there are three similar ways to get key events and that they aren’t equally treated by browsers. In the end I got through it. I’m looking forward to building on this and then trying some ruby!