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
| var sampleArray = [0,0,7]; | |
| var incrementLastArrayElement = function(_array) { | |
| var newArray = []; | |
| // Your code should make newArray equal to an array that has the same | |
| // values as _array, but the last number has increased by one. | |
| // For example: | |
| // _array = [1, 2, 3]; | |
| // turns into: |
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
| var s = "audacity"; | |
| var udacityizer = function(s) { | |
| // Right now, the variable s === "audacity" | |
| // Manipulate s to make it equal to "Udacity" | |
| // Your code goes here! | |
| s = s.charAt(1).toUpperCase() + s.slice(2); | |
| return s; | |
| }; |
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
| /* | |
| * Programming Quiz: Donuts Revisited (7-6) | |
| */ | |
| var donuts = [ | |
| { type: "Jelly", cost: 1.22 }, | |
| { type: "Chocolate", cost: 2.45 }, | |
| { type: "Cider", cost: 1.59 }, | |
| { type: "Boston Cream", cost: 5.99 } | |
| ]; |
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
| /* | |
| * Programming Quiz: Facebook Friends (7-5) | |
| */ | |
| // your code goes here | |
| var facebookProfile = { | |
| name: "Claudia", | |
| friends: 100, | |
| messages: ["Happy birthday", "I love you", "XOXO", "Bless you"], |
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
| /* | |
| * Programming Quiz: Bank Accounts 1 (7-3) | |
| */ | |
| var savingsAccount = { | |
| balance: 1000, | |
| interestRatePercent: 1, | |
| deposit: function addMoney(amount) { | |
| if (amount > 0) { | |
| savingsAccount.balance += amount; |
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
| /* | |
| * Programming Quiz: Nested Numbers (6-10) | |
| * | |
| * - The `numbers` variable is an array of arrays. | |
| * - Use a nested `for` loop to cycle through `numbers`. | |
| * - Convert each even number to the string "even" | |
| * - Convert each odd number to the string "odd" | |
| */ | |
| var numbers = [ |
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
| /* | |
| * Programming Quiz: I Got Bills (6-9) | |
| */ | |
| var bills = [50.23, 19.12, 34.01, 100.11, 12.15, 9.90, | |
| 29.11, 12.99, 10.00, 99.22, 102.20, 100.10, 6.77, 2.22]; | |
| var totals = bills.map(function(bill){ | |
| bill += (bill * (15/100)); | |
| return Number(bill.toFixed(2)); |
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
| /* | |
| * Programming Quiz: Another Type of Loop (6-8) | |
| * | |
| * Use the existing `test` variable and write a `forEach` loop | |
| * that adds 100 to each number that is divisible by 3. | |
| * | |
| * Things to note: | |
| * - you must use an `if` statement to verify code is divisible by 3 | |
| * - you can use `console.log` to verify the `test` variable when you're finished looping | |
| */ |
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
| function hasEnoughPlayers(team){ | |
| return (team.length >= 7) ? true : false; | |
| } | |
| var team = ["Oliver Wood", "Angelina Johnson", "Katie Bell", "Alicia Spinnet", "George Weasley", "Fred Weasley", "Harry Potter"]; | |
| console.log(hasEnoughPlayers(team)); |
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
| /* | |
| * Programming Quiz: Colors of the Rainbow (6-4) | |
| */ | |
| var rainbow = ["Red", "Orange", "Blackberry", "Blue"]; | |
| rainbow.splice( 2, 1, "Yellow", "Green"); | |
| rainbow.push("Purple"); |