Skip to content

Instantly share code, notes, and snippets.

View sandrabosk's full-sized avatar
👩‍💻
Always a student, never a master. Have to keep moving forward. ~C.Hall

Aleksandra Bošković sandrabosk

👩‍💻
Always a student, never a master. Have to keep moving forward. ~C.Hall
  • Ironhack
View GitHub Profile

Create a new component ProductCreate and have its initial state as shown below. Create a form and corresponding methods to handle input changes as well as form submission. You can display a newly created product on the DOM or alert it, as we did in the previous example.

// ProductCreate/index.js

import React from 'react';

class ProductCreate extends React.Component {
  // the initial state
 state = {

Use the example from the previous exercise (products array) and render the text next to each product depending if the product is in stock or is not in stock.

Create a new component ProductsList and save in its state the given array of products. Display all the products (their name and price, not paying attention to the inStock property):

// ...
state = {
  products: [
    {
      _id: '34rg',
      name: 'iron hat',
 price: 11.99,

Create an HTML document with one canvas on it. In a separate JS file, fetch the canvas and create on it three squares on the bottom of it. Make the squares move from the bottom to the top of the canvas. You can choose the speed in which they move.

Respond to the following questions:

  • What is an em? You can explain it through an example.
  • What is the difference between em and rem?
  • In your own words, how would you describe "mobile-first" design?
const numbers = [3, 5, 6, 2];
  • Exercise 1: Reverse the array (numbers).

  • Exercise 2: Sort an array (numbers) and then reverse it.

  • Exercise 3: Reverse a string:

const arrOfStrings = ['cat', 'wolf', 'yo', 'animal'];
  • Exercise 1: Using the array (arrOfStrings), sort an array from shortest string to the longest.

  • Exercise 2: Using the same arr (arrOfStrings), sort its elements alphabetically.

  • Exercise 3: Sort the objects in the array by age, in descending order.

  1. Given an array of numbers, filter out the numbers that are not even, and are less than 100.
const numbers = [1, 60, 112, 123, 100, 99, 73, ];

// ... your code here
  1. From the given array of people, get the people who are allowed to consume alcoholic beverages (based on the US law). Bonus: Get just their names, we don't need their age.
  1. Calculate the total population in the given array (data):
const data = [
  {
    country: 'USA',
    pop: 340,
  },
  {
 country: 'France',
  1. What is expected output and why?
const firstName = 'ivan';
const lastName = 'ivan';
console.log(firstName === lastName); // => ???

let currency = '$';
let currencyUS = currency;
console.log(currency == currencyUS); // => ???