Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion starter-code/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<title>Advanced Collection Methods</title>
<script src="./lib/abbeyRoad.js"></script>
<script src="./lib/harryPotter.js"></script>
<!-- connect your new JavaScript file here -->
<script src="./lib/Harrypotterexercise.js"></script>
<script src="./lib/abbeyRoadExercise.js"></script>
</head>

<body>
Expand Down
23 changes: 23 additions & 0 deletions starter-code/lib/Harrypotterexercise.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function birthdaysArranged (array) {
var newArray = [];
for (var i=0; i<array.length; i+=2) {
var temp = [];
temp.push(array[i],array[i+1]);
newArray.push(temp);
}
return newArray;
}

console.log (birthdaysArranged(birthdays));

var moreBirthdays = [ "Lily Evans", "30 January", "James Potter", "27 March",
"Dudley Dursley", "30 June", "Tom Riddle", "31 December" ];


console.log (birthdaysArranged(moreBirthdays));


var birthday1 = birthdaysArranged(birthdays);
var birthday2 = birthdaysArranged(moreBirthdays);

console.log(birthday1.concat(birthday2));
49 changes: 49 additions & 0 deletions starter-code/lib/Iteration3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
var goodPsswd = "1234567890";
var badPsswd = "1123456";

var noRepeatChar = function (password) {
for (var i=0; i<password.length; i++) {
if ((password.indexOf(password[i]))!==i) {
return "Bad password";
}
}
return "Good password";
};

console.log(noRepeatChar(goodPsswd));
//"Good password."

console.log(noRepeatChar(badPsswd));
// "Ouch, bad password."


var goodPsswd = "1234567890";
var badPsswd = "1a234567890";

var onlyNumbers = function (password) {
for (var i=0; i<password.length; i++) {
if (isNaN(password[i])) {
return "Bad password";
}
}
return "Good password";
};

console.log(onlyNumbers(goodPsswd));
// "Good password."

console.log(onlyNumbers(badPsswd));
// "Ouch, bad password."



var goodPsswd = "1234567890";
var badPsswd = "12345678901234567890";

var trimPassword = function (password) {
return password.substring(0,9);
};


console.log(trimPassword(badPsswd));
// "1234567890"
11 changes: 11 additions & 0 deletions starter-code/lib/abbeyRoadExercise.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var novemberSongs = abbeyRoadRecords.filter( function(songs) {
return songs.month=11;
});

console.log(novemberSongs);

var novemberArtists = novemberSongs.map ( function(songs) {
return songs.artist;
});

console.log(novemberArtists);