Skip to content

Instantly share code, notes, and snippets.

View josecarneiro's full-sized avatar

José Carneiro josecarneiro

View GitHub Profile
// Queue
class Queue {
constructor() {
this.queueControl = [];
this.MAX_SIZE = 10;
}
display() {
return this.queueControl;
class Chronometer {
constructor() {
this.currentTime = 0;
this.intervalId = null;
}
start(callback) {
this.intervalId = setInterval(() => {
this.currentTime++;
if (callback) callback();
// ITERATION 1
function updateSubtotal(product) {
console.log('Calculating subtotal, yey!');
//... your code goes here
const priceElement = product.querySelector('.price span');
const quantityElement = product.querySelector('.quantity input');
/* eslint no-restricted-globals: 'off' */
// Iteration 1: All directors? - Get the array of all directors.
// _Bonus_: It seems some of the directors had directed multiple movies so they will pop up multiple times in the array of directors. How could you "clean" a bit this array and make it unified (without duplicates)?
const getAllDirectors = (movies) => {
return movies.map((movie) => movie.director);
};
// Iteration 2: Steven Spielberg. The best? - How many drama movies did STEVEN SPIELBERG direct?
// memory.js contents
class MemoryGame {
constructor(cards) {
this.cards = cards;
this.pickedCards = [];
this.pairsClicked = 0;
this.pairsGuessed = 0;
}
// Write your Pizza Builder JavaScript in this file.
// Constants
let basePrice = 10;
let ingredients = {
pepperoni: { name: 'pepperoni', price: 1 },
mushrooms: { name: 'Mushrooms', price: 1 },
greenPeppers: { name: 'Green Peppers', price: 1 },
whiteSauce: { name: 'White sauce', price: 3 },
glutenFreeCrust: { name: 'Gluten-free crust', price: 5 }
@josecarneiro
josecarneiro / index.html
Created June 10, 2021 18:17
ironhack-6-2021-recipes-lab-solution
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Apple Pie Recipe</title>
<!-- don't forget to link your styles -->
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
href="https://fonts.googleapis.com/css2?family=Lato:wght@300;400&display=swap"
// Iteration #1: Find the maximum
function maxOfTwoNumbers(a, b) {
// if (a > b) {
// return a;
// } else if (b > a) {
// return b;
// } else {
// return a;
// }
// if (a > b) {
// Iteration 1: All directors? - Get the array of all directors.
// _Bonus_: It seems some of the directors had directed multiple movies so they will pop up multiple times in the array of directors.
// How could you "clean" a bit this array and make it unified (without duplicates)?
function getAllDirectors(movies) {
// const directors = [];
// for (const movie of movies) {
// directors.push(movie.director);
// }
// const directors = movies.map((movie) => {
// return movie.director;
// ITERATION 1
function updateSubtotal(productElement) {
const productPriceElement = productElement.querySelector('.price span');
const productQuantityInputElement =
productElement.querySelector('.quantity input');
const priceValue = Number(productPriceElement.innerText);
const quantityValue = productQuantityInputElement.valueAsNumber;