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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:39:35+00:00 2026-05-22T02:39:35+00:00

recently I got a job interview for a web developer position. They ask me

  • 0

recently I got a job interview for a web developer position.

They ask me to create a javascript object that keep accurate score in
a ten-pin bowling match for a single player.

I have accomplished my test.

You can run the script at this url http://jsbin.com/arele5,

If you want to edit just go to this link http://jsbin.com/arele5/edit

I have two questions:

1) The javascript object works on google chrome but jsbin complains about the following construction

var bowlingGame = new function(){...};

If I correct the construction in the following way

var bowlingGame = function(){...};

the jsbin says to me that all things are ok, but it doesn’t work in google chrome. Any ideas?

2) I didn’t pass the job interview, indeed I didn’t receive any response; so my second question is:

what would be the best way to solve the exercise?

Thanks,

Antonio

  • 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-22T02:39:36+00:00Added an answer on May 22, 2026 at 2:39 am

    For #1, try:

    var bowlingGame = new (function(){ ...})();
    

    As for #2, I can’t exactly say why you didn’t get a job, but the spacing of your code, if nothing else, isn’t very pretty to look at. I just wrote this, it’s much more compact and easy to read:

    function game(){
        this.balls = [];
    }
    
    game.prototype = {
        addBalls : function(n){
            this.balls.push.apply(this.balls, arguments);
        },
    
        getScoreArray : function(){
            var score=0, ball=0, frame=1, frames=[], cur;
            for(var i=0, l=this.balls.length; i<l; i++){
                score += (cur = this.balls[i])
                    + ((!ball && frame<10 && cur==10 && this.balls[i+2]) || 0)
                    + (frame<10 && (((ball ? this.balls[i-1] : 0) + cur) == 10) ? this.balls[i+1] || 0 : 0);
                ball = ball || (cur==10) ? 0 : 1;
                ball || (frame<10 ? frames.push(score) && frame++ : frames[9] = score);
            }
    
            return frames;
        }
    };
    

    If nothing else, run your code through something like: http://jsbeautifier.org/ if you can’t keep indentation clean…

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

Sidebar

Related Questions

I recently got hired as a web developer, and the project that I am
I started a new job recently. I've been a Java & XML web developer
I recently botched a job interview by poorly answering a straightforward question: how do
I recently got a job working for a company who uses several programming languages
Just recently got into experimenting with NLog, and it occurs to me that I
I recently got a notification from a McAfee service (what used to be called
I recently got involved in a Java project at work: we're using MyEclipse for
I just recently got my first mac. I do lots of programming on windows
A colleague of mine recently got bitten badly by writing out of bounds to
I'm involved in building a donation form for non-profits. We recently got hit by

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.