Note: I do a lot of work with JSON objects using JSONATA (try.jsonata.org). Please keep that in mind regarding my question.
In the Price Range exercise, Mosh creates an array with the objects:
let priceRanges = [
{ label: '$', tooltip: 'Inexpensive', minPerPerson: 0, maxPerPerson: 10 },
{ label: '$$', tooltip: 'Moderate', minPerPerson: 11, maxPerPerson: 20 },
{ label: '$$$', tooltip: 'Expensive', minPerPerson: 21, maxPerPerson: 50 },
]
However, my answer
const priceRange = {
low: {
min: 0,
max: 100,
display: '$',
toolTip: 'Inexpensive'
},
medium: {
min: 101,
max: 200,
display: '$$',
toolTip: 'Moderate'
},
high: {
min: 201,
max: 999,
display: '$$$',
toolTip: 'Expensive'
}
}
I make the assumption that the interpreter would imply that the object was an array of objects. This is assumption is based on JSON’s interpretation of the object, and the ability of JSONATA to count the array.
Is this a ‘you can do it either way’ thing or a specific concept that is trying to be taught?