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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:53:33+00:00 2026-06-01T11:53:33+00:00

Hello I’m working on a problem that requires me to change an set array

  • 0

Hello I’m working on a problem that requires me to change an set array of numbers into an array that returns the original numbers as a function. So we get a return of a2 instead of a[2].

I dont want the answer I just need a hint. I know i can loop through the array and use .pop() to get the last value of the array, but then I dont know how to convert it to a function from there. any hints?

  • 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-01T11:53:34+00:00Added an answer on June 1, 2026 at 11:53 am
    var numToFun = [1, 2, 3];
    var numToFunLength = numToFun.length;
    
    for (var i = 0; i < numToFunLength; i++) {
        (function(num){
            numToFun.unshift(function() {
                return num;
            });
        }(numToFun.pop())) 
    }
    

    DEMO

    basically it pops out a number from the last, builds a function with that number returned, and put back into the first of the array. after one full cycle, all of them are functions.

    here’s the catch: how this works, it’s up to you to research

    why the loop does not look like the straightforward pop-unshift:

    for (var i = 0; i < numToFunLength; i++) {
        numToFun.unshift(function() { //put into first a function
            return numToFun.pop()     //that returns a number
        });
    }
    

    and why i did this: (HINT: performance)

    var numToFunLength = numToFun.length;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello i´m trying to set info from a post method into a variable that
Hello I am working with a simulator that uses rcS scripts to boot, this
Hello guys I need to pass a string array over to a setter that
Hello I have this problem with PyQt4-dev-tools that include: * a user interface compiler
Hello i have a problem with c# Arrays. I need a array to store
Hello, Im working on a solution for Android that will record calls (both out
Hello Stack Overflow users, I have a fun problem that I have in my
Hello I am compiling a program with make but I get the error of
Hello , I am currently working on the student association's website. The student's association
hello friends i am trying to get a list of user id and want

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.