Multiply in a return && Decimal rounder

It’s a variable, you wrote it in your code as user_input, I just mistyped

There one basic data structure in JS, Objects. You define using object literals like:

const example = {
  foo: 1
  bar: 2
}

The keys are strings. Values are anything.

Set values like example.foo = 2.
Access values like example.foo.
Access values you don’t know the key for (as is the case for you, where the name of the key is held in a variable) like example[someVariable]

Arrays are a special type of object where the keys are integers that go from 0 upwards, and they automatically reindex those numbers when you add or remove things. The values can be anything. They are an ordered lost of values.

And you define using array literals like:

const example = [10, 20, 45, 74];

Don’t do this: new Array(). You can do this Array() (Array is a constructor function that does not need the new keyword), but the array literal syntax above is how you would do it 99.9% of the time.

You can access like example[0]
You can set directly like example[0] = "new value"

A Map is another special type of object, which is an ordered collection of key value pairs. The keys and the values can be of any type. It is basically what is called an associative array in other languages.

You can just use objects, thats easiest thing:

const cupcakePrices = {
  cc12: 12,
  cc18: 18,
  cc24: 24,
  ...and so on
}

What do you mean by “got it to work with a const”? There isn’t really anything special about const (or let, or var)

1 Like