mana Posted December 1, 2015 Share Posted December 1, 2015 hello, i have the following file, it is a Color guess game. i want when the Color is not in my Array there would be a message. but it doesn't work. can you help me please? aslo i want after reaching to the target Color the Background Color would be as the same as the desired Color. can oyu help me please how to corret this code? thnak you Untitled-laughing-squid.html Link to comment Share on other sites More sharing options...
justsomeguy Posted December 1, 2015 Share Posted December 1, 2015 You can paste code in a code box here instead of attaching files, it's easier when people can just see the code. Make sure you're using your browser's developer console, you should see error messages. One will say that colors.indexof is undefined, because Javascript is case-sensitive. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf Also read the description of what it does, if it returns 0 then it found the element in the array. Your if statement is checking if it returned 0, but that doesn't mean that the element wasn't found. When you change the CSS, use backgroundColor instead of just background. You may need some CSS to set the width and height of the body since you don't have any elements on the page. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now