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 8864789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:20:21+00:00 2026-06-14T16:20:21+00:00

I would like to randomize three arrays for fonts, font size, font weight. I

  • 0

I would like to randomize three arrays for fonts, font size, font weight.
I then need to display the results of the three arrays in a div, with a class name of randomFont.
So each time I use the class randomFont, it will return a random font/size/weight.

Any ideas on how I would go about doing this?

Let’s say I have 3 variables in each array.

  • array 1 (fonts) > font 1, font 2, font 3
  • array 2 (font weight) > bold, light, 100
  • array 3 (font-size) > 12px, 24px, 100px

Then I want an an array to randomly choose one from each and display the output in a div>class called randomFont.

How would I do this?

  • 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-14T16:20:23+00:00Added an answer on June 14, 2026 at 4:20 pm

    You can see one approach at http://jsfiddle.net/CrossEye/bwsvy/

    var fonts = ['Arial', 'Helvetica', 'Georgia', 'Tahoma', 'Verdana'];
    var weights = ['normal', 'bold', 'lighter'];
    var sizes = ['16px', '20px', '24px', '36px', '40px'];
    
    var choose = function(arr) {
        return arr[Math.floor(Math.random() * arr.length)];
    };
    
    // ...
    var text = choose(sizes) + ' ' + choose(weights) + ' '  +  choose(fonts);
    output.innerHTML = '<div class="randomFont">' + text + '</div>';
    // e.g. '24px bold Tahoma'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My query selects results correctly using ORDER BY CASE. I would like to randomize
Would like to be able to set colors of headings and such, different font
Would like to know how to hide an div after a set of css3
I would like to randomize the output of the numbers at the end of
I need to query my database and partially order and randomize the results. For
I would like to know how I can randomize the order in which some
I would like to declare (and randomize) about 500 strings. I believe I have
I have a list of type System.IO.FileInfo , and I would like to randomize
I would like to make a image randomizer/slider that randomly displays an image from
Would like to parse IPv4 address from exit-addresses . Format of the file: ExitNode

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.