Skip to content

Instantly share code, notes, and snippets.

View josecarneiro's full-sized avatar

José Carneiro josecarneiro

View GitHub Profile
import React from 'react';
import './FaceBook.css';
import profiles from './../data/berlin.json';
// import profiles from '../data/berlin.json';
class FaceBook extends React.Component {
state = {
profiles: profiles,
selectedCountry: null
import React from 'react';
import './App.css';
import contacts from './contacts.json';
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
people: contacts.slice(0, 5)
};
/* 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?
const cartElement = document.querySelector('#cart tbody');
const calcElement = document.getElementById('calc');
function updateSubtot(productElement) {
// Iteration 1.1
const priceSpanElement = productElement.querySelector('.pu span');
const priceValue = priceSpanElement.innerText;
const quantityInputElement = productElement.querySelector('input');
const quantityValue = quantityInputElement.value;
// ITERATION 1
// Suspects Collection
const suspectsArray = [
{
firstName: 'Jacob',
lastName: 'Green',
occupation: 'Entrepreneur',
age: 45,
// ITERATION 1
// Suspects Collection
const suspectsArray = [
{
firstName: 'Jacob',
lastName: 'Green',
occupation: 'Entrepreneur',
age: 45,
description: 'He has a lot of connections',
// Iteration #1: Find the maximum
function maxOfTwoNumbers(a, b) {
if (a > b) {
return a;
} else {
return b;
}
}
// Iteration #2: Find longest word
import React from 'react';
import './App.css';
import contacts from './contacts.json';
class App extends React.Component {
constructor() {
super();
this.state = {
list: contacts.slice(0, 5),
};
const category = 'Entertainment';
// const image = `/images/${category.toLowerCase()}.jpeg`;
let image;
switch (category) {
case 'Travel':
image = '/images/travel.jpeg';
break;
/* 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?