forked from sf-wdi-22-23/debug-drills
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.js
47 lines (38 loc) · 1.02 KB
/
scripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
console.log("Sanity Check: JS is working!");
$(document).ready(function(){
console.log("The DOM is ready!");
// squash the bugs isn't showing up
function addSubHeader() {
var subHeader = $('<small>  squash the bugs!</small>')
$('h1').append(subHeader);
}
addSubHeader;
// the form redirects when it should just update the count of "E"s
$('form').on('submit', function(e){
console.log('form submitted');
var input = $('input').eq(0).val();
// should count occurrences of the letter "E"
// and update the display. instead always shows 0
for (var i = 0; i < 10; i++){
var count = 0;
if (input[i] === "e"){
count = count +1;
}
$('#num-es').text(count);
}
});
// all the links alert 5 :(
function addLinks () {
var $link;
var $ul = $('ul');
for (var i=0; i<5; i++) {
$link = $('<a href="#"></a>');
$link.html('Link '+i);
$link.on('click', function () {
alert(i);
});
$ul.append($link);
}
}
addLinks();
};