I learned math.random and math.floor through websites but still stuck in the middle of my code. I’m newbie js is my first language.
//Create a business name generator by combining list of Adjective and Shop name and Another Word
let a = math.floor(math.random() * 3);
let b = math.floor(math.random() * 3);
let c = math.floor(math.random() * 3);
let Adjectives = {
0: Crazy,
1: Amazing,
2: Fire,
}
let ShopName = {
0: Engine,
1: Foods,
2: Garments,
}
let AnotherWords = {
0: Bros,
1: Limited,
2: Hub,
}
console.log(`${Adjectives[a]} ${ShopName[b]} ${AnotherWords[c]}`);
Expected answer = Crazy Engine Limited/ Amazing Garments Bros (Any 3 words combining and making a name)
3
Answers
It’s a type-o
math
should beMath
🙂edit: Also, your Adjectives, ShopName and OtherWords should be arrays and not object.
example:
You can either use the default
Math
library or import a library such asmaths
to get your expected outcome. Here, I suppose you are trying to use the default math library (i.e. Math).Also please make sure that your string values must be within quotes (
"
).Alternatively, you can use a list instead of a numbered directory.