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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:07:55+00:00 2026-05-18T06:07:55+00:00

Javascript = looked through Google and Stack Overflow -I am still lost as I

  • 0

Javascript = looked through Google and Stack Overflow -I am still lost as I am still new in programming and everything else. I have some questions that I need to know

so far, I have this below:

var getUrladdress = window.location.href; //get current url address
var sortbydiscount = "?sortby";
var discount = ["20","30","50","70"];

What I wanted to know how to do is:

  1. append string from discount array (I have tried to use append() but it doesn’t work 🙁
  2. then compare the discount array against percentDiscount (still being worked on in other question)
  3. sort the items (final one) to display all items under 20%, 30% etc group.

Could you please give me insight/guide me on how to append string from discount array and then have the url show that “http://www.xxx.com?sortby30” in live address bar?
Then could it be possible to compare array against percentDiscount?

Many thank yous in advance.

EDITED:: #3 – I wanted to have sale items categorized in different discount group: i.e. if 20%, then all items which are on sale for 20% should be only displayed on the page.

  • 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-18T06:07:56+00:00Added an answer on May 18, 2026 at 6:07 am

    You really should get a good book on JavaScript and learn from that if you are so unsure about core language features. That said:

    1. You are confusing appending an HTML element using jQuery (just one of the web application libraries or “frameworks” available for JavaScript) with appending one string to another (concatenating strings). The plus operator can be used to concatenate strings:

      getUrladdress = getUrladdress + sortbydiscount;
      
    2. To check to see if a particular item is in an array, you can use the .indexOf method of the array. Because the method was added only in ES5 (the latest version of the ECMAScript/JavaScript specification), the documentation I have linked to includes contains some compatibility code to use to get this to work on Internet Explorer.

      if(discount.indexOf(percentdiscount) != -1) {
          // found
      } else {
          // not found
      }
      
    3. I’m not sure what you mean by that one; perhaps you can clarify exactly what you are trying to do? Show a list of items under each discount percentage on the web page?

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

Sidebar

Related Questions

I've looked at Google's map API, which is all javascript and terribly slow on
I've got it to work, and I have looked online and through the documentation,
I've looked for some help on the reddit site itself, but I still can't
I've looked through the other related posts to my question already over the past
I have an array of items as follows in Javascript: var users = Array();
I have a script that appends some rows to a table. One of the
First of all: I looked through other posts on stackoverflow and none of them
JavaScript post request like a form submit shows you how to submit a form
JavaScript allows functions to be treated as objects--if you first define a variable as
JavaScript does funky automatic conversions with objects: var o = {toString: function() {return 40;

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.