JavaScript Remove specific values from an array remove specific values from list python,remove specific values in

I'm in the process of making a code that prints all numbers divisable by 3 using an array, but im having trouble removing specific values. All the values i want prints correctly, but what i want is to exclude the numbers 27, 33, 300, 450, even tough they are correct.

ive tried messing with the splice function, and i know i can restructure the code without using arrays alltogheter. but i really want to use arrays to get a better understanding of what i can do with them.

<script>

    var div = division(1000);
    var j=0;
    function division(num){
        var threes = [];
    for (var i = 1; i <num; i++) {
        j=i%3
        if (j===0) {
        threes.push(i);
            }
        }
        return threes;
    }
    document.write(div);

</script>

this code correctly prints all the values between 1 and 1000 divisable by 3, but ive yet to find a good method to remove the above specified values.

Answer:1

Try this

div.filter(x=>![27, 33, 300, 450].includes(x))

var div = division(1000);
    var j=0;
    function division(num){
        var threes = [];
    for (var i = 1; i <num; i++) {
        j=i%3
        if (j===0) {
        threes.push(i);
            }
        }
        return threes;
    }

    div = div.filter(x=>![27, 33, 300, 450].includes(x));

    document.write(div);
Answer:2

From MDN article about strict mode: First, strict mode makes it impossible to accidentally create global variables. In normal JavaScript mistyping a variable in an assignment creates a new ...

From MDN article about strict mode: First, strict mode makes it impossible to accidentally create global variables. In normal JavaScript mistyping a variable in an assignment creates a new ...

  1. what does javascript do
  2. what does javascript mean
  3. what does javascript look like
  4. what does javascript void mean
  5. what does javascript need to work on a website
  6. what does javascript compile to
  7. what does javascript stand for
  8. what does javascript void(0)
  9. what does javascript code look like
  10. what does javascript do for a website
  11. what does javascript do in html
  12. what does javascript run on
  13. what does javascript error mean
  14. what does javascript eval do
  15. what does javascript map return
  16. what does javascript developer do
  17. what does javascript require do
  18. what does javascript trim do
  19. what does javascript await do
  20. what does javascript have to do with java

I'm trying to create an array of hours in a day with 30 minute intervals with moment.js and ES6. Example: let hours = ["12:00 AM", "12:30 AM", "1:00 AM", "1:30 AM", ..., "11:30 PM"] I already have ...

I'm trying to create an array of hours in a day with 30 minute intervals with moment.js and ES6. Example: let hours = ["12:00 AM", "12:30 AM", "1:00 AM", "1:30 AM", ..., "11:30 PM"] I already have ...

I have an automatically playing slideshow (controlled by jQuery/JS), that requires each image to be absolutely positioned. The problem is that I'm trying to horizontally centre this slideshow on my ...

I have an automatically playing slideshow (controlled by jQuery/JS), that requires each image to be absolutely positioned. The problem is that I'm trying to horizontally centre this slideshow on my ...

I am trying to catch an element using an ID in React, but I could not. render() { //Looping through all menus let menuOptions = this.props.menuLists.map(menuList => { return ( <li ...

I am trying to catch an element using an ID in React, but I could not. render() { //Looping through all menus let menuOptions = this.props.menuLists.map(menuList => { return ( <li ...

  1. object inside react component