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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:38:53+00:00 2026-05-27T22:38:53+00:00

I have a problem with this script, something is going wrong. Rnumer stays undefined.This

  • 0

I have a problem with this script, something is going wrong.
Rnumer stays undefined.This script should return and write all uneven digits from the random number list. Can someone tell me what I do wrong. Thanks in advance

var Rnumber = new Array();

for (i = 0; i<= 100;i++)
{
    Rnumber[i] = Math.ceil(Math.random()*101);
//  document.write(Rnumber[i] + "<br/>");
}

function unevenAndDivisible(Rnumber)
{
    var remainder = new Array();    

    for (i = 0; i<= 100; i++)
    {
        remainder = parseInt(Rnumber[i])%2;
    }
    return remainder;
}

document.write(unevenAndDivisible());

Changed to

var Rnumber = new Array();

for (i = 0; i<= 100;i++)
{
    Rnumber[i] = Math.ceil(Math.random()*101);
//  document.write(Rnumber[i] + "<br/>");
}

function unevenAndDivisible(Rnumber)
{
    var remainder = new Array();

    for (i = 0; i<= 100; i++)
    {
        remainder[i] = Rnumber[i]%2;
    }
    return remainder;
}
document.write(unevenAndDivisible(Rnumber));

but now i get the result :
0,1,0,0,1,0,0,0,1,1,0,0,1,0,1,1,1….

I simply want maybe I asked it wrong the first time, to write al uneven numbers from the random list of Rnumbers
Then I need to divide that through 7 and return that.

EDIT

Allmost all problems are clear , thanks everyone for that.
Their is still one question left:
In this code below it only take the first uneven value from remainder and I want that it takes all values that are uneven to the next if statement to check %7.
Maybe you see the problem better if you run it for youreself

var Rnumber = new Array();

for (i = 0; i<= 100;i++)
{
    Rnumber[i] = Math.ceil(Math.random()*101);
}

function unevenAndDivisible()
{
    var remainder = [];
    var answer = [];
    for (i = 0; i<= 100; i++)
    {
        if (Rnumber[i]%2 !== 0)
        {
            remainder.push(Rnumber[i]); 

            for (c = 0; c <= remainder.length;c++)
            {
                if (remainder[c]%7 == 0)
                {
                    answer.push(remainder[c]);
                }
            }           
        }
    }
    return answer;
}

answer = unevenAndDivisible();
document.write(answer);

Problem solved , Thanks everyone

  • 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-05-27T22:38:54+00:00Added an answer on May 27, 2026 at 10:38 pm

    You don’t need to pass Rnumber to the function, as it’s already available in scope:

    function unevenAndDivisible()
        {
            var remainder = [];
    
            for (i = 0; i<= 100; i++)
            {
                if (Rnumber[i]%2 !== 0) {
                    remainder.push(Rnumber[i]);
                }
    
            }
            return remainder;
        }
    
    remainder = unevenAndDivisible();
    console.log(remainder);
    

    JS Fiddle demo.


    Edited in response to question from OP (in comments to question, above):

    …can someone explain what this mean: var remainder = [];

    Sure, it’s array-literal notation, which is equal to: var remainder = new Array();, it’s just a little more concise, and I prefer to save myself the typing. I get the impression, from JS Lint, whenever I use var x = new Array(); therein that the above version is generally preferred (since it complains otherwise), but I don’t know why.

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

Sidebar

Related Questions

I have this .bat script which I use to maven package my application. Problem
I have this html code <html> <head> <title>JQuery Problem 2</title> <script type=text/javascript src=jquery-1.4.min.js></script> <script
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I have problem with this code: file = tempfile.TemporaryFile(mode='wrb') file.write(base64.b64decode(data)) file.flush() os.fsync(file) # file.seek(0)
I have a script element in my webpage, something like this: <script id=myscript></script> Now,
Hi i have problem with this code, i found it on the internet and
i am a beginner and i have a problem : this code doesnt compile
I have this problem I'm hoping someone knows the answer to. I have an
I have this problem where I open Visual Studio and the internal windows are
i have this problem to find a particular xml node l have post 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.