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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:58:35+00:00 2026-06-15T01:58:35+00:00

I got an array with different school grades. This data is gathered from a

  • 0

I got an array with different school grades. This data is gathered from a json file. In this array there are also grades that are 0. These are grades from students that didn’t complete the course. I want to remove all the 0 in the array, but I have no idea how to start.

example of the array:

var grades = [7,6,4,0,4,8,9,6,6,10,0,7,8,6,7]

p.s. I’m using d3

  • 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-15T01:58:36+00:00Added an answer on June 15, 2026 at 1:58 am

    You can try Array.filter:

    var nonzero = grades.filter(function(v) {
        return v !== 0;
    });
    

    As commenteers correctly noted, .filter is not avail in all browsers. You can use the shim available on MDN (see link above), or re-write your code to something like this:

    var i=0, len = grades.length, nonzero = [];
    for(;i<len;i++) {
        grades[i] !== 0 && nonzero.push(grades[i]);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I got a PHP file that returns an array of different results (the
I've got an array of strings that looks like this: [noindex,nofollow] or [index, follow,
I've got an array of different sized images. I want to place these images
I've got a prewritten function in C that fills an 1-D array with data,
I got this problem from an interview with Microsoft. Given an array of random
I've got an array of @contacts that is being iterated on a different model
I got an array of char with 8 positions(char data[8];), this array has an
I got the array of disabled text boxes from the database. When I click
I got an array which contains signed int data, i need to convert each
I got an array like that Array ( [0] => Array ( [UnitESN] =>

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.