Created
June 17, 2015 13:03
-
-
Save edwinwebb/c3fc41283c5e13240461 to your computer and use it in GitHub Desktop.
Spot the errors
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
/* | |
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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There are good few errors and improvements to be made in this code. Can you spot them all?