It was FUN,
it took about 20min
Love U CodeCademy
Using your code as the basis, here is a version using getters…
const message = {
_type: [" brand new", "n old,", " rusty,"],
_color: ["black", "white", "red", "silver"],
_car: ["Benz", "Corvette", "BMW", "Dodge"],
rnd (n) {
return Math.floor(Math.random() * n)
},
get type () {
return this._type[this.rnd(this._type.length)];
},
get color () {
return this._color[this.rnd(this._color.length)];
},
get car () {
return this._car[this.rnd(this._car.length)];
},
};
const FortuneTeller = () => {
console.log(`\nYour Future Car is:\n** A${message.type} ${message.color} ${message.car} **\n`)
};
FortuneTeller();
I tweaked the grammar a smidge and abstracted away the Math stuff.
WoW, Nice
, But, I don’t really get along with getters , I really like a hero function to do all kinds of stuff and save the project
In the above, remove get
and all the backing prefixes, then add ()
to the string literal expressions.
${message.type()}
Cool
I’m impressed