Skip to content

Instantly share code, notes, and snippets.

@edwinwebb
Created June 17, 2015 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save edwinwebb/c3fc41283c5e13240461 to your computer and use it in GitHub Desktop.
Save edwinwebb/c3fc41283c5e13240461 to your computer and use it in GitHub Desktop.
Spot the errors
/*
JavaScript Test
---------------
A small script to open a popup when clicking a link.
Once you click on the button, clinking on it again will close the popup.
*/
/* Task One - Improve this code
var close = 'Close List';
var open = 'Open List';
var isOpen = false;
var FirstButton = document.getElementById('#1st-button");
var HTMLElement = document.getElementById('#Pop-Up');
var load = fucntion() {
FirstButton.innerText = open;
FirstButton.addEventListener('onClick', function(Event) {
isOpen = isOpen ? false : true;
open(HTMLElement, isOpen);
if(isOpen)
FirstButton.css('background-color', rgba(234,54,43);
else
FirstButton.innerText = isOpen ? open : close;
return isOpen = true;
}
}
var open = function(element, close) {
element.css('display', close : 'none' ? 'block');
}
window.addEventListener(onLoad, function onLoad() {load()});
open(FirstButton, isOpen);
@edwinwebb
Copy link
Author

There are good few errors and improvements to be made in this code. Can you spot them all?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment