Skip to content

Instantly share code, notes, and snippets.

View claudiainbytes's full-sized avatar

Claudia Estupiñán Forero claudiainbytes

View GitHub Profile
/*
* 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));
/*
* 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
*/
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));
/*
* Programming Quiz: Colors of the Rainbow (6-4)
*/
var rainbow = ["Red", "Orange", "Blackberry", "Blue"];
rainbow.splice( 2, 1, "Yellow", "Green");
rainbow.push("Purple");
// don't change this code
function emotions(myString, myFunc) {
console.log("I am " + myString + ", " + myFunc(2));
}
emotions("happy", function (num){
var x = 1;
var output = "";
while ( x <= num ){
output += "ha";
var cry = function x(){
return "boohoo!";
};
console.log(cry());
/*
* Programming Quiz: Laugh (5-4)
*/
var laugh = function(num){
var x = 1;
var output = "";
while ( x <= num ){
output += "ha";
x++;
/*
* Programming Quiz: Build A Triangle (5-3)
*/
// creates a line of * for a given length
function makeLine(length) {
var line = "";
for (var j = 1; j <= length; j++) {
line += "* ";
}
/*
* Programming Quiz: Laugh it Off 2 (5-2)
*/
// declare your function
// then, call it!
// print the output with console.log
function laugh(num){
var x = 1;
/*
* Programming Quiz: Find my Seat (4-8)
*
* Write a nested for loop to print out all of the different seat combinations in the theater.
* The first row-seat combination should be 0-0
* The last row-seat combination will be 25-99
*
* Things to note:
* - the row and seat numbers start at 0, not 1
* - the highest seat number is 99, not 100