Chapter 4

Data Structures: Objects and Arrays

Objects and arrays (which are a specific kind of object) provide ways to group several values into a single value. Conceptually, this allows us to put a bunch of related things in a bag and run around with the bag, instead of wrapping our arms around all of the individual things and trying to hold on to them separately

The sum of a range

Adjust the range of animals to be shown through the dropdown selectors. Each animal represents a value from 1 to 10. Sum of animals represents the sum of the selected animals.
Bear
Bear
Boar
Boar
Buffalo
Buffalo
Monkey
Monkey
Elephant
Elephant
Hippo
Hippo
Lion
Lion
Lynx
Lynx
Ostrich
Ostrich
Wolf
Wolf

Select an option to display animals

to

Sum of animals

55

Reversing an array

The first, Click to reverse, takes an array as argument and produces a new array that has the same elements in the inverse order. The second, Click to reverse in place, modifies the array given as argument by reversing its elements

🟡🟢🟣🔴⚪️

12345

A list

The first tab in yellow shows a dropdown with cities, and then the green button randomly adds a new city at the beginning of the list. Under, it renders the countries and flags of every city listed above. On the right in blue color, displays the main dish recommended for the first element of the list
Cities I would like to visit
  • Paris

    No more cities to visit

Countries of the listed cities above

France 🇫🇷
There are more cities to add!
The main dish is Ratatouille

Deep comparison

Compare two objects representing 2 lists and return true only if they have the same properties and values. Use the +/- buttons to add or remove properties

Grocery of last week

  • 🥚 Eggs

    6x Large class A free range eggs

    2.5 $

  • 🐓 Chicken

    650gr Fresh Class A skinless chicken breast fillet portions.

    4.7 $

  • 🍚 Basmati rice

    1kg Aromatic & fluffy A long, slender grain grown in the foothills of the Himalayas

    2.5 $

  • 🥔 Potatoes

    1kg White potatoes

    1.5 $

Grocery of this week

  • 🥚 Eggs

    6x Large class A free range eggs

    2.5 $

  • 🐓 Chicken

    650gr Fresh Class A skinless chicken breast fillet portions.

    4.7 $

  • 🍚 Basmati rice

    1kg Aromatic & fluffy A long, slender grain grown in the foothills of the Himalayas

    2.5 $

  • 🥔 Potatoes

    1kg White potatoes

    1.5 $

It is the same list

Sum of a range

Drag the sliders to specify the range of numbers to sum

Sum: 578

Reversion arrays

First button creates a new array with the elements in the inverse order. Second button reverses the array in place

😀😄😁😆🤣

🍊🍈🍉🍋🍓

Prepend to linked list

Add new items as the first element of the linked list and see how the list changes below
May
the Force
🚀
be
with
you 🫵

Compare two texts

Tap on each text to randomly change their styles and see if they are equal
❌ Text styles do not match