Last active
December 23, 2015 15:09
-
-
Save shankarcabus/3f9d4b884a2c85f0f4a3 to your computer and use it in GitHub Desktop.
Test to interview front-enders
http://webreflection.blogspot.com.br/2010/09/rebecca-murpheys-challenge.html
https://gist.github.com/furf/577989
This file contains 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
// how could you rewrite the following to make it shorter? | |
if (foo) { | |
bar.doSomething(el); | |
} else { | |
bar.doSomethingElse(el); | |
} | |
// how could this code be rewritten in order to remove the if? | |
if (foo) { | |
bar.doSomething(); | |
} | |
// given the following code, and assuming that each created object has a | |
// 'destroy' method, how would you destroy all of the objects contained in the | |
// myObjects object? | |
var myObjects = { | |
thinger : new myApp.Thinger(), | |
gizmo : new myApp.Gizmo(), | |
widget : new myApp.Widget() | |
}; | |
// how could you improve the following code? | |
$(document).ready(function() { | |
$('.foo #bar').css('color', 'red'); | |
$('.foo #bar').css('border', '1px solid blue'); | |
$('.foo #bar').text('new text!'); | |
$('.foo #bar').removeClass('btn'); | |
$('.foo #bar').removeClass('primary'); | |
$('.foo #bar').click(function() { | |
$(this).attr('title', 'new title'); | |
$(this).width('100px'); | |
}); | |
$('.foo #bar').click(); | |
}); | |
// how would you improve the following code? | |
for (i = 0; i <= 100; i++) { | |
$('#thinger').append('<p><span class="thinger">i am thinger ' + i + '</span></p>'); | |
$('#gizmo').append('<p><span class="gizmo">i am gizmo ' + i + '</span></p>'); | |
} | |
/* | |
According to the following HTML: | |
<div id="button">button</div> | |
<button id="alert">Click me!</button> | |
How to improve and make the code below work? | |
*/ | |
$("#button").click(function(){ | |
$("body").append('<button class="btn" id="alert">Click now!</button>'); | |
}); | |
$("#alert").click(function(){ | |
alert('Alert clicked'); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment