Remove the outer darkColorArr
array from the line of code.
const darkColorsArr = [
"#2C3E50",
"#34495E",
"#2C2C2C",
"#616A6B",
"#4A235A",
"#2F4F4F",
"#0E4B5A",
"#36454F",
"#2C3E50",
"#800020",
];
function getRandomIndex() {
console.log([Math.floor(darkColorsArr.length * Math.random())])
getRandomIndex();
You removed the array name only, also remove it’s brackets
const darkColorsArr = [
"#2C3E50",
"#34495E",
"#2C2C2C",
"#616A6B",
"#4A235A",
"#2F4F4F",
"#0E4B5A",
"#36454F",
"#2C3E50",
"#800020",
];
function getRandomIndex() {
console.log[Math.floor(darkColorsArr.length * Math.random()]
getRandomIndex();
You deleted the console log brackets.
const darkColorsArr = [
"#2C3E50",
"#34495E",
"#2C2C2C",
"#616A6B",
"#4A235A",
"#2F4F4F",
"#0E4B5A",
"#36454F",
"#2C3E50",
"#800020",
];
function getRandomIndex() {
console.log([Math.floor(darkColorsArr.length * Math.random()])
getRandomIndex();
How the array Syntex looks like? Remove the array Syntex from your code.
function getRandomIndex() {
console.log([Math.floor( Math.random()])
getRandomIndex();
You have removed the already existing code. You need to remove only array around your code.
Array example:
let array = [];
You need to remove array from your code.
function getRandomIndex() {
console.log([Math.floor(darkColorsArr.length * Math.random()])
getRandomIndex();
You still have array []
within your code.
const darkColorsArr = [
"#2C3E50",
"#34495E",
"#2C2C2C",
"#616A6B",
"#4A235A",
"#2F4F4F",
"#0E4B5A",
"#36454F",
"#2C3E50",
"#800020",
];
function getRandomIndex() {
console.log(Math.floor(darkColorsArr.length * Math.random())
getRandomIndex();
Now you need to close your function. You are missing the closing bracket }
after your code. Place it before getRandomIndex call.
const darkColorsArr = [
"#2C3E50",
"#34495E",
"#2C2C2C",
"#616A6B",
"#4A235A",
"#2F4F4F",
"#0E4B5A",
"#36454F",
"#2C3E50",
"#800020",
];
function getRandomIndex() {
console.log(Math.floor(darkColorsArr.length * Math.random())
};
getRandomIndex()
Now, your code is working from my end. Copy the above code and reset the challenge step. And try to add it again.
it is still not working
Share your code again.
const darkColorsArr = [
"#2C3E50",
"#34495E",
"#2C2C2C",
"#616A6B",
"#4A235A",
"#2F4F4F",
"#0E4B5A",
"#36454F",
"#2C3E50",
"#800020",
];
function getRandomIndex() {
console.log(Math.floor(darkColorsArr.length * Math.random())
};
getRandomIndex();
Try to copy paste only the above code line.