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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:28:24+00:00 2026-06-03T23:28:24+00:00

items = 3; $(‘#div’).html(items + 1 + ‘ – ‘ + items + 3);

  • 0
items = 3;
$('#div').html(items + 1 + ' - ' + items + 3);

Trying to make #div display 4 - 6, but it instead shows 4 - 33. What am I missing?

  • 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-03T23:28:25+00:00Added an answer on June 3, 2026 at 11:28 pm

    As to why it happened:

    first the parser reads items + 1, so fine and dandy, it’s 4

    then it concatenates with ' - ', so now you have 4 -

    then it sees + items, at this moment, you are dealing with String, so it concatenates with 3 (as items is 3), so you have 4 - 3

    then you have another concatenation with 3, but the left operand is a string, so the right operand is type casted into String as well, so you have 4 - 33

    To achieve what you want, you need to enclose the inner operations:

    $('#div').html((items + 1) + ' - ' + (items + 3));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im trying to display items in a list view based on my raw query.
My items are listed as follows; This is just a summary of course. But
I have items contained in an unordered list. I have hidden divs (using display:none;)
I'm adding the items programatically, but MKUserTrackingBarButtonItem doesn't seem to offer any way to
That shows all work items having more completed hours than original estimate?
Items are stored with x,y coordinates. The .items div starts at [0,0] and is
My application shows several items whereby users can search. I want to place a
items: house: - bathroom: - toothbrush - soap - bedroom: - bed: - pillow
The Items collection of a ListView contains the actual business objects. How do I
HttpContext.Current.Items is a store that has a life span of the HTTP request. I'd

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.