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

  • Home
  • SEARCH
  • 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 8358977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:59:20+00:00 2026-06-09T10:59:20+00:00

This is my code, acting upon myArray : var myArray = []; var i;

  • 0

This is my code, acting upon myArray:

var myArray = [];
var i;

for(i = 0; i < 20; i += 1) {
   myArray.push(Math.random());
}

Is there a functional equivalent of the above that does without the dummy variable i?

Favorite answers:

  • while(myArray.push(Math.random()) < 20);
  • $.map(Array(20), Math.random);
  • for(var myArray = []; myArray.push(Math.random()) < 20;);
  • 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-09T10:59:24+00:00Added an answer on June 9, 2026 at 10:59 am

    Not in ES5, there’s no real functional equivalent to it, as you have to have something which has an amount of 20 to apply map to…

    var my20ElementArray = [0,1,2,3,4,5,6,7,8,9,10];
    var myArray = my20ElementArray.map(Math.random);
    

    You could create an xrange-like function what is in Python but that would just hide this “unused” variable inside a function.

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

Sidebar

Related Questions

anyone can explain me, why this parts of code are acting differently? while((c =
This code is the core of a much larger script that works great in
i'm setting a cookie using this code: setcookie(Blah,user,time()+86400); i'm then checking that cookie on
I have some code that appears to behave differently between PHP 4 and PHP 5. This
I do this: // Note: FbApp is set outside of this code (var FbApp
Given this Bash code: TEMP=1_2 echo ${TEMP/_.*/} why does it print out 1_2 instead
This code below allows me to find the word error in all my files
This code disabled mouse scroll functionality, when i click on the document. $(document).on(click, function
This code only renders a dodecahedron and completely ignores the glBegin(GL_TRIANGLES) block: glutSolidDodecahedron(); glBegin(GL_TRIANGLES);
This code gives me this error:Cannot implicitly convert type ArrayList[] to ArrayList[][] at this

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.