Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9203165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:24:42+00:00 2026-06-17T23:24:42+00:00

I have a little script that I’ve written to generate a random color hex

  • 0

I have a little script that I’ve written to generate a random color hex code. It goes like this:

function genHex() {
    colors = new Array(14)
    colors[0] = '0'
    colors[1] = '1'
    colors[2] = '2'
    colors[3] = '3'
    colors[4] = '4'
    colors[5] = '5'
    colors[6] = '6'
    colors[7] = '7'
    colors[8] = '8'
    colors[9] = '9'
    colors[10] = 'a'
    colors[11] = 'b'
    colors[12] = 'c'
    colors[13] = 'd'
    colors[14] = 'e'
    colors[15] = 'f'

    digit = new Array(5)
    color = ""
    for (i = 0; i < 6; i++) {
        digit[i] = colors[Math.round(Math.random() * 14)]
        color = color + digit[i]
    }
    return color;
}

I know this isn’t the prettiest way to accomplish what I’m doing, but the means will ultimately serve a different end for a more complex project. Regardless, when I include this genhex.js file alongside the latest Jquery, nothing works!

For instance,

$().ready(function() {
    alert(genhex());
});

does nothing. What am I missing here? Is there some reason that color not a string in this case?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:24:44+00:00Added an answer on June 17, 2026 at 11:24 pm

    Try:

    $(function() {
        alert(genHex());
    });
    

    To call genHex() on document ready.

    Also the function is defined as genHex() but you’re trying to call it as genhex(). Function names are case-sensitive in JavaScript.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this little script that generate a table in a .pdf file, but
I have a little script that is used to generate a random string of
I have this little script that shows one wisdom each day. so I have
I have found this little script in PHP that send a simple request to
I have a little VBA script with some functions that I would like to
I have a little php script that goes to mySql database. I want to
I have written a small little script that looks up a work on wikipedia
I have tried to write this little script that will batch rename file extensions.
I have this little script repeated below in my code a few times. I
I have this little script that gets information from an excel file. After I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.