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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:46:02+00:00 2026-06-02T16:46:02+00:00

I am creating an HTML5 app that will display a bunch of shapes in

  • 0

I am creating an HTML5 app that will display a bunch of shapes in different colors. I am having trouble display more than one of any shape.

Here is a JSFiddle link to my project: http://jsfiddle.net/tithos/3uyLc/

Here is one of the things I tried:

$("#go").click(function() {
  var number = $("#number option:selected").val();
  var shape = $("#shape option:selected").val();
  var size = $("#size option:selected").val();
  var offset = size;
  var i = 0;
  var shift = 0;

  while(i < number){
    switch(shape){
      case '1':
        console.log(shift);
        square((offset+shift), size);
        shift = (shift + size);
        break;
      case '2':
        circle(offset, size);
        break;
      case '3':
        triangle(offset, size);
        break;
    }
    i++;
  }
});

This, when repeated 16 times, gives me “0121212121212121212121212121212” in the concole. It is concatenating, not adding. Why?

Any help or insights are welcome

Thanks,

Tim

  • 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-02T16:46:04+00:00Added an answer on June 2, 2026 at 4:46 pm

    Since .val() returns a string you are using + operator between two strings, which is the concatenation operator. Use parseInt to convert a string to integer.

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

Sidebar

Related Questions

I'm creating a web app that allows users to enter a number of colors,
I am creating a mobile app that will connect to a zendamf implementation to
I'm creating an app that has separate server and client code (two different git
I'm creating an iOS app that will upload a file to a specific collection
I'm working on creating an app that will parse MSDN articles for meta-information such
I am new with android development.I am creating an app that will tell the
I am programming for iPhone, creating an app that shows various locally stored HTML
I'm creating a new plugin for a jruby on rails application that will eventually
I am creating an HTML5 app for a blackberry playbook. I am wondering how
What I'm doing: I'm creating a sample app that shows how to incorporate Kendo

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.