How can I update the pins on a google map using fetch each time a slide changes?

I have a Google map set up in a Slider Revolution slider and it pulls locations from a database. I have it set up so that it updates every 10 seconds, which works, but it seems that any time it runs and the map slide is not active, the pins disappear until the next time it updates. I would like it to update after each slide change.

This is the code that works for updating every 10 seconds:

function fetch(){
  var mapsvg = this;
  setInterval(()=>{ 
  mapsvg.database.find() 
  }, 133000);
}
fetch();

This is the code that I tried to use for updating after slide change:

revapi2.bind("revolution.slide.onafterswap",function fetch(){
     var mapsvg = this;
    mapsvg.database.find();
 
})
fetch();

I get two errors with this code:

Uncaught (in promise) TypeError: Window.fetch: At least 1 argument required, but only 0 passed

and

Uncaught TypeError: mapsvg.database is undefined

Any help would be most appreciated.

Why is my dungeon generation algorithm crashing?

Seemingly arbitrarily, my code will crash when trying to add flooring to a new room. The tab will freeze up, and this error occurs seemingly anywhere where I try to generate a room. This occurs on Edge, Firefox, and Chrome. The following is my index JS file, and is where the function to add flooring to the room is called.

import {Character} from "./Character.js";
import {Player} from "./Player.js"
import {Room} from "./Room.js"

const canvas = document.getElementById("game");
const ctx = canvas.getContext("2d");


canvas.width = 1280;
canvas.height = 768;
ctx.fillRect(0, 0, 1280, 768);

let enemies = [];
let rooms = [];
let activeHitboxes = [];
let isMouseClicked = false;
let mousePosX = 640;
let mousePosY = 360;
let currentRoom = -1;
let player;
let intervalCode = 0;
let score;

document.body.onkeydown = function (e) {
    if (e.key === " " ||
        e.code === "Space"
    ) {
        if(intervalCode !== 0){
        clearInterval(intervalCode);}
        startGame();
    }
}

canvas.onmousedown = (event) => { //update mouseclick status
    const {
        mousePress = true
    } = event;
    isMouseClicked = mousePress;
}

canvas.onmouseup = (event) => {
    const {
        mousePress = false
    } = event;
    isMouseClicked = mousePress;
}

canvas.onmousemove = (event) => { //update mouse position
    const {
        clientX, clientY
    } = event
    mousePosX = clientX - event.currentTarget.getBoundingClientRect().left
    mousePosY = clientY - event.currentTarget.getBoundingClientRect().top
}


function animate() { //gameplay loop
    ctx.fillStyle = '#000'
    ctx.fillRect(0, 0, 1280, 768);

    rooms[currentRoom].draw();

    for (let i = 0; i < rooms[currentRoom].hCells; i++) {
        for (let j = 0; j < rooms[currentRoom].vCells; j++) {

            if (rooms[currentRoom].tiles[i][j].type === 2) {
                activeHitboxes.push({
                    width: 64,
                    height: 64,
                    x: rooms[currentRoom].tiles[i][j].location.x,
                    y: rooms[currentRoom].tiles[i][j].location.y,
                    isSourcePlayer: false,
                    isDoor: false
                })
                activeHitboxes.push({
                    width: 64,
                    height: 64,
                    x: rooms[currentRoom].tiles[i][j].location.x,
                    y: rooms[currentRoom].tiles[i][j].location.y,
                    isSourcePlayer: true,
                    isDoor: false
                })
            } else if (rooms[currentRoom].tiles[i][j].type === 4) {


                if (i === 0) {
                    activeHitboxes.push({
                        width: 64,
                        height: 64,
                        x: rooms[currentRoom].tiles[i][j].location.x,
                        y: rooms[currentRoom].tiles[i][j].location.y,
                        isSourcePlayer: true,
                        isDoor: true,
                        isEntry: true
                    })
                    activeHitboxes.push({
                        width: 64,
                        height: 64,
                        x: rooms[currentRoom].tiles[i][j].location.x,
                        y: rooms[currentRoom].tiles[i][j].location.y,
                        isSourcePlayer: false,
                        isDoor: true,
                        isEntry: true

                    })
                }


                activeHitboxes.push({
                    width: 64,
                    height: 64,
                    x: rooms[currentRoom].tiles[i][j].location.x,
                    y: rooms[currentRoom].tiles[i][j].location.y,
                    isSourcePlayer: true,
                    isDoor: true,
                    isEntry: false
                })

                activeHitboxes.push({
                    width: 64,
                    height: 64,
                    x: rooms[currentRoom].tiles[i][j].location.x,
                    y: rooms[currentRoom].tiles[i][j].location.y,
                    isSourcePlayer: false,
                    isDoor: true,
                    isEntry: false

                })
            }
        }
    }


    player.updateMouse(mousePosX, mousePosY, isMouseClicked);
    checkHits(player);
    if (player.getHealth() > 0) {
        player.update(activeHitboxes);
    } else {
        player.shrink(1);
        player.draw();
        ctx.font = "48px inter";
        ctx.fillStyle = "#fff"
        ctx.strokeText("PRESS SPACE TO RETRY", canvas.width / 2 - 281, canvas.height / 2)
        ctx.fillText("PRESS SPACE TO RETRY", canvas.width / 2 - 281, canvas.height / 2)
    }
    for (let i = 0; i < enemies.length; i++) {
        enemies[i].update();
        checkHits(enemies[i]);
        checkHits(player);
    }
    activeHitboxes = [];
}

function generateRoom(x, y, ctx) {
    let room = new Room(768, 1280, x, y, ctx);
    room.fillRoom();
    room.addFloor(x, y);
    if (rooms.length <= 1) {
        room.addDoors();
    } else (
        room.addDoors(rooms[currentRoom - 1].getDoors())
    )
    rooms.push(room);
    currentRoom += 1;
}

function checkHits(target) { //check active hitboxes against a target
    for (let i = 0; i < activeHitboxes.length; i++) {
        checkHit(target, activeHitboxes[i].x, activeHitboxes[i].y, activeHitboxes[i].width, activeHitboxes[i].height, activeHitboxes[i].isSourcePlayer, activeHitboxes[i].isDoor, activeHitboxes[i].isEntry)
    }
}

function checkHit(target, hitboxX, hitboxY, hitboxWidth, hitboxHeight, isSourcePlayer, isDoor, isEntry) { //judge if a hitbox connected with a target
    if (hitboxX < target.getPosition().x + target.getWidth() && //if hit connects, and they're on opposite teams, remove 1 health from target;
        hitboxX + hitboxWidth > target.getPosition().x &&
        hitboxY < target.getPosition().y + target.getHeight() &&
        hitboxY + hitboxHeight > target.getPosition().y &&
        (target.isPlayer && !isSourcePlayer || !target.isPlayer && isSourcePlayer)) {
        if (isDoor && !isEntry) {
            console.log("Isnt entry")
            console.log(currentRoom);
            generateRoom(0, rooms[currentRoom].getDoors(), ctx);
            player.setPosition(96, rooms[currentRoom - 1].getDoors() * 64)
        } else if (isEntry && currentRoom >= 1) {
            console.log("Is entry")
            console.log(currentRoom);
            currentRoom--;
        } else {
            target.removeHealth();
            if (target.getHealth() === 0 && enemies.includes(target)) {
                enemies.splice(enemies.indexOf(target), 1);
            }
        }
    }
}

function startGame() {
    enemies = [];
    rooms = [];
    activeHitboxes = [];
    isMouseClicked = false;
    mousePosX = 640;
    mousePosY = 360;
    currentRoom = -1;

    player = new Player({
        position: {x: 32, y: 32},
        height: 32,
        width: 16,
        health: 1,
        ctx: ctx,
        isPlayer: true,
    });


    const enemy = new Character({
        position: {x: 400, y: 100},
        height: 32,
        width: 32,
        health: 1,
        ctx: ctx,
        isPlayer: false,

    });

    generateRoom(0, 0, ctx);
    enemies.push(enemy);
    player.draw();
    for (let i = 0; i < enemies.length; i++) {
        enemies[i].draw();
    }
    intervalCode = setInterval(animate, 1000 / 60);
}

ctx.font = "48px inter";
ctx.fillStyle = "#fff"
ctx.strokeText("PRESS SPACE TO START", canvas.width / 2 - 281, canvas.height / 2)
ctx.fillText("PRESS SPACE TO START", canvas.width / 2 - 281, canvas.height / 2)

The room class is here

import {Tiles} from "./Tiles.js";

export class Room {
    vCells;//Number of vertical tiles, 11
    hCells;//number of horizontal tiles, 19
    height;
    width;
    location;
    tiles = [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []];
    walkable = [[]];

    constructor(height, width, x, y, ctx) {
        this.height = height;
        this.width = width;
        this.location = {x: x, y: y};
        this.ctx = ctx;
        this.vCells = height / 64;
        this.hCells = width / 64;
    }

    fillRoom() {
        for (let i = 0; i < this.width / 64; i++) {
            for (let j = 0; j < this.height / 64; j++) {
                this.tiles[i][j] = (new Tiles(i * 64, j * 64, 2));
            }
        }

    }

    addFloor(x, y) {//randomized prim's algorithm to place walkable floor

        let startTile = this.tiles[x][y]; //get tile
        startTile.setType(3);//set start tile to floor


        //compute a frontier list, all wall tiles that are 2 "steps" away from our starting tile are stored in this list if these tiles are valid
        let frontier = []
        this.getNeighbours(x, y, frontier, 2);
        //while this frontier list is not empty, pick an arbitrary tile from this list
        while (frontier.length > 0) {
            let idx = this.getRandomInt(0, frontier.length);
            let frontierNeighbours = [];
            let pickedFrontier = frontier[idx];
            if (this.getNeighbours(pickedFrontier.location.x / 64, pickedFrontier.location.y / 64, frontierNeighbours, 3)) {//make a list of all neighbours to that frontier tile (tiles 2 distance away that are floors)

                let neighbourIDX = this.getRandomInt(0, frontierNeighbours.length);
                let neighbourX = frontierNeighbours[neighbourIDX].location.x / 64;
                let neighbourY = frontierNeighbours[neighbourIDX].location.y / 64;

                let x = pickedFrontier.location.x / 64;
                let y = pickedFrontier.location.y / 64;
                let xDiff = x - neighbourX;
                let yDiff = y - neighbourY;
                let connectorX = 0;
                let connectorY = 0;

                if (xDiff > 0) {
                    connectorX = neighbourX + 1;
                } else if (xDiff < 0) {
                    connectorX = neighbourX - 1;
                } else {
                    connectorX = neighbourX;
                }
                if (yDiff > 0) {
                    connectorY = neighbourY + 1;
                } else if (connectorY < 0) {
                    connectorY = neighbourY - 1;
                } else {
                    connectorY = neighbourY
                }
                this.getNeighbours(connectorX, connectorY, frontier, 2);
                // this.getNeighbours(x, y, frontier, 2);

                if (this.isValid(connectorX, connectorY)) {
                    this.tiles[connectorX][connectorY].setType(3);
                    this.walkable.push(this.tiles[connectorX][connectorY]);
                }
                frontier.splice(idx, 1);
            }
        }
    }


    getNeighbours(x, y, arr, type) { //Get tiles 2 blocks away

        let hasNeighbour = false;

        for (let i = -2; i <= 2; i += 2) {
            for (let j = -2; j <= 2; j += 2) {
                if (this.isValid(x + i, y + j) && this.tiles[x + i][y + j].type === type && ((Math.abs(x - x + i) >= 2 || Math.abs(y - y + j) >= 2) && ((Math.abs(x - x + i) + Math.abs(y - y + j)) !== 4))) {
                    if (!arr.includes(this.tiles[x + i][y + j])) {
                        hasNeighbour = true;
                        arr.push(this.tiles[x + i][y + j]);
                        // this.tiles[x + i][y + j].setType(0)
                    }
                }
            }
        }
        return hasNeighbour;
    }

    canAccess(x, y) {
        for (let i = -1; i <= 0; i++) {
            for (let j = -1; j <= 0; j++) {
                if (this.isValid(x + i, y + j) && Math.abs(j + i) !== 2) {
                    if (this.tiles[x + i][y + j].type === 3) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

    isValid(x, y) {
        if (x >= this.hCells) {
            return false;
        }
        if (y >= this.vCells) {
            return false;
        }
        if (x < 0) {
            return false;
        }
        if (y < 0) {
            return false;
        }
        return true;
    }

    

    getDoors() {
        for (let j = 0; j < this.vCells; j++) {
            if (this.tiles[this.hCells - 1][j].type === 4) {
                return j;
            }
        }
        return -1;
    }

    getRandomInt(min, max) {
        min = Math.ceil(min);
        max = Math.floor(max);
        return Math.floor(Math.random() * (max - min) + min); //maximum is exclusive and minimum is inclusive
    }

    draw() {
        for (let i = 0; i < this.tiles.length; i++) {
            for (let j = 0; j < this.tiles[i].length; j++) {

                if (this.tiles[i][j].type === 0) {
                    this.ctx.fillStyle = '#000'
                }
                if (this.tiles[i][j].type === 1) {
                    this.ctx.fillStyle = '#f00'
                }
                if (this.tiles[i][j].type === 2) {
                    this.ctx.fillStyle = '#000'
                }
                if (this.tiles[i][j].type === 3) {
                    this.ctx.fillStyle = '#555'
                }
                if (this.tiles[i][j].type === 4) {
                    this.ctx.fillStyle = '#00F'
                }
                this.ctx.fillRect(this.tiles[i][j].location.x, this.tiles[i][j].location.y, this.tiles[i][j].size, this.tiles[i][j].size);

            }
        }
    }
}

performance recording here

as an aside, any javaScript specific advice is also welcome since this is my first Javascript program, Thanks.

SFTP with javascript and SQL, where do I even start? server recommendations? or just general advice

So my school has hired me to help make a website for them, this is my first job and I’m very grateful for the opportunity. I am going to be making them a website with connected db for them to look at data. The site they are currently using to collect the data can automate the sending of said data but it seems to only do this through SFTP, I was wondering is it possible to connect SFTP to a JavaScript server. And how/where do I start. I’m sorry if this has been asked before, but I have been trying to google for a solution for the past few days and keep coming up empty handed.

My current plan is to create the site and connected database using node.js (and express.js) to connect with a SQL database (I don’t know if this is relevant but I will be accessing the SQL database using MySQL) Since I am unfamiliar with SFTP I will just have a part of the site where they can upload their data. This will require them to download the data from the previously used site, and from what I’ve gathered they seem to be semi-constantly getting new data so this would get tedious fast. I am hoping that SFTP can be used to eliminate this, and make the site and nice as possible for them.

I can give any more details as necessary, as I may have left something out. I am grateful to anyone who helps or even takes the time to read this so, Thanks a bunch!

Need help comparing an object generated from a form submission agaisnt a previous submission

So I am building a data collection software that relies heavily on forms and form validations. I have currently built up dynamic forms with Formik and Yup with individual validation but im looking to dive deeper into validating the users current input agaisnt a previous input to make sure the value of the same key from the objects are incrementing or decrementing based on the form settings.

const ObjOne = 
{
   NumberOne: 100,
   NumberTwo: 200,
   NumberThree: 300,
}
const ObjTwo = 
{
   NumberOne: 150,
   NumberTwo: 250,
   NumberThree: 350,
}

I want to setup some sort of system to compare these two objects to validate that the users current submission for NumberOne in Object Two is properly incrementing higher than the previous value in Object One. If said value is not incrementing then it would return an error telling the user the data is not valid.

If someone could help me brainstorm on how to acheive this or point me in the proper direction i would greatly appreciate it.

How do I make a PG SQL ilike query in Javascript injection safe?

I want to have a simple search box in my web application using Javascript/Node.js and Postgresql. In it I have a form which is open for the public to make searches for names. I am not using any ORM so how do I make this type of search query safe in the backend, while using .then() ?

I want to use sort of SELECT * FROM spotters WHERE last_name ilike '%Burns%' but safely. The code below doesn’t work, but how can I solve this? It feels like it should be quite easy.

// req.query.name = 'Burns' --- Could be "';DROP TABLE"!
pg_client.query("SELECT * FROM spotters WHERE last_name ilike '%?%'", [req.query.name])
  .then((sqlResult) => {
// handle result
  })

I want to have code similar to the above where it can ilike-search for column last name with a query received from the search input.

How to fade down and up a css class value using Javascript

The website uses a class

.myDivider {
background-size:100% 210px!important;
height:210px!important;
}

I would need a JS code, that fades changes both 210 to 100 within a few seconds, but not hard like in one step.
When faded down to 100 then fade it up again to 210. And down again. Endless.

Do you have any idea?

Thx so far
Regards
C

Divide a number into equal values and push to an array

I need to divide a number equally and push the values on the array. I’m using 100 as an example,
but when I do it, it goes [28, 24, 24, 24], and I need it to be [25, 25, 25, 25]

const divide = () => {
  var number = 100
  var n = 4

  var values = []
  while(number > 0 && n > 0){
    var a = Math.floor(number / n / 4) * 4
    number -= a
    n--
    values.push(a)
  }

  console.log(values)
}

How to set a value to true if an object exists in a list

I have a three lists, the first one is like this

[
  true,
  ['keyToOffice', false],
  false
]

The second one is like this:

[
  {
    reference: 'keyToOffice',
    a load of other irrelevant stuff
  },
  {
    reference: 'keyToHouse',
    a load of other irrelevant stuff
  }
]

The third one, my inventory is like this:

[
  'keyToOffice'
]

I would like to know if there is a way to update the second value of all the lists in the first list to true if the first item is inside of the third list.
What would happen is that in ['keyToOffice', false], the false would become true because it is in the inventory list. If 'keyToOffice' was not in the inventory, then the false would stay false

How to modularize code while creating HTML elements in JavaScript?

I am writing a piece of code to basically call in the top money earner and the top five money earners in a given data set. While writing the code, I realized that there were a couple of spots where I was rewriting the code, basically copying and pasting it. While that works, I wanted to throw the duplicate portion of the code and call it from a function. However, that is not working and I don’t exactly know why. Here is the code that is duplicated:

duplicate code

Here is the function I made to be called. However, when I call it, it’s not working as expected, where the information shows up on the webpage. I’m using VS Code and am running this on live server so when I save, the webpage automatically updates.

function to be called

where function called

How to redirect to another page after successful Google Sign In in React18?

I am having an issue when trying to redirect to a different page after signing in with Google with my React 18 project. After logging in with google no redirects happen and I have no clue why not. Here is my Login.jsx file.
After clicking the Google Login button on my react page and successfully logging in with Google nothing changes.

import React from 'react';
import { GoogleLogin } from 'react-google-login';
import { GoogleLogout } from 'react-google-login';
import { createRoot } from 'react-dom/client';
import { useNavigate } from 'react-router-dom';
import { FcGoogle } from 'react-icons/fc';
import shareVideo from '../assets/share.mp4';
import logo from '../assets/logowhite.png';

import { client } from '../client';

const Login = () => {

  const navigate = useNavigate();

  const responseGoogle= (response) => {
    localStorage.setItem('user', JSON.stringify(response.profile.Obj));

    const { name, googleId, imageUrl } = response.profileObj;

    const doc = {
      _id: googleId,
      _type: 'user',
      userName: name,
      image: imageUrl,
    }

    client.createIfNotExists(doc)
      .then(() => {
        navigate('/', { replace: true })
      })
  }
  return (
    <div className='flex justify-start items-center flex-col h-screen'>
      <div className='relative w-full h-full'>
          <video 
            src={shareVideo}
            type='video/mp4'
            loop
            controls={false}
            muted
            autoPlay
            className='w-full h-full object-cover'
          />
          <div className='absolute flex flex-col justify-center items-center top-0 right-0 left-0 bottom-0 bg-blackOverlay'>
              <div className='p-5'>
                  <img src={logo} width='130px' alt='Ack! This WAS a logo :/' />
              </div>

              <div className='shadow-2xl'>
                    <GoogleLogin 
                      clientId="380323139927-1809a59ll0fp29rfo40jmubp01c2ife8.apps.googleusercontent.com"
                      render={(renderProps) => (
                        <button
                          type='button'
                          className='bg-mainColor flex justify-center items-center p-3 rounded-lg cursor-pointer outline-none'
                          onClick={renderProps.onClick}
                          disabled={renderProps.disabled}
                          onSuccess={responseGoogle}
                          onFailure={responseGoogle}
                          cookiepolicy='single-host-origin'
                        >
                          <FcGoogle className='mr-4' /> Sign in with Google
                        </button>
                      )}  
                      
                    />
              </div>
          </div>
      </div>
    </div>
  )
}

export default Login

Here is my index.js file if needed:

import React, { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import { BrowserRouter as Router } from 'react-router-dom';

import App from './App';
import './index.css'

const rootElement = document.getElementById("root");
const root = createRoot(rootElement);


root.render(
    <Router>
    <App />
    </Router>, 
    document.getElementById('root')
    );

If anyone knows anyway to sort this out I would appreciate it hugely. Thanks in advance.

Is there a way to pass the OnSelect value of a dropdown inside a component, to App.js

I have a searchbar component that contains my dropdown in question. I am wanting to get the selections from the OnSelect value of the dropdown component and pass them to App.js to be used in the handler below.

App.js handler

 const [value, setValue] = useState("");
const dropdownHandler = (e) => {
  console.log(e);
  setValue(e);
};

Normally I would be able to set the onSelect method, to dropdownHandler directly, if the component was inside of App.js. However, I am unsure of how to do this when the components are modular.

Searchbar.js

 <DropdownButton className="dropdown"
      title="Search Filters"
      id="dropdown-menu"
      // onSelect={dropdownHandler}
    >
      <Dropdown.Item eventKey="ddFirstName">First Name</Dropdown.Item>
      <Dropdown.Item eventKey="ddLastName">Last Name</Dropdown.Item>
      <Dropdown.Item eventKey="ddTitle">Title</Dropdown.Item>
      <Dropdown.Item eventKey="ddPhoneNumber">Phone Number</Dropdown.Item>
      <Dropdown.Item eventKey="ddLocation">Location</Dropdown.Item>
    </DropdownButton>

App.js calling the searchbar component.

  <div className="centered-container">
      <Searchbar
          searchQuery={searchQuery}
          setSearchQuery={setSearchQuery}
        />
      </div>

What is the best way to pass the value from this dropdown back to App.js, so I can use the handler function I have written?

VSCode git commit not working but not generating errors

I’m working on a portfolio website and a few days ago created the github and began commiting changes. I made 2 commits that day, but none of my other commits the day after and today have synced to the repository. I am saving files, staging changes, and not getting errors. Really not sure how to fix this.

How to convert javascript obj into URL parameters with nested object in it?

I have a react app that handles routing in the application. I am getting json object from db with parameters that will look like this:

    let paramsObj = {
        state: {
            Corp: "CorpCode",
            Location: "LocationCode",
            IsCorp: false
        }
    };

How to convert paramsObj and encode it to URL parameters so the final string would look like this?state=%7B%20Corp%3A%20%22CorpCode%22%2C%20Location%3A%20%22LocationCode%22%2C%20IsCorp%3A%20false%20%7D

Setting a dynamic css maximum grid row value

from my research, it seems to appear that only way to set the final value of a CSS grid is to either specify it, or create/manipulate the css :root value.

but what if the number of rows is unknown when the grid is first created?

below is an example of what i am trying to achieve. i am creating a random value and setting the css grid-row-end value accordingly using a css variable --ending upon completion.

does the CSS grid have a way to do this, something like a css-row-end: max?

<html>
<head>
<style>
    .wrapper {
      display: grid;
      grid-template-columns: 150px 100px;
      grid-gap: 10px;
      background-color: #fff;
      color: #444;
    }

    .box {
      background-color: #444;
      color: #fff;
      border-radius: 5px;
      padding: 20px;
      font-size: 151%;
    }
</style>
<script>
'use strict;'
    const maxNbrOfRows = 8;
    window.onload = () => {
        const nbrOfRows = Math.floor(Math.random() * maxNbrOfRows) + 1;
        for ( let i=1; i <= nbrOfRows; i++ )    {
            let tag = document.createElement('div');
            let text = document.createTextNode('row ' + i.toString() );
            tag.appendChild(text);
            tag.classList.add('box');
            tag.style.gridColumnStart = '2';
            let element = document.getElementById('grid');
            element.appendChild(tag);
        }
             // hack the css :root value
        document.styleSheets[0].insertRule(':root { --ending: ' + nbrOfRows.toString() + '; }');
    }

</script>

</head>
<body>
    <div id='grid' class="wrapper">
        <div style='grid-row-end: span var(--ending);' class="box a">First Col</div>
    </div>
</div
</body>
</html>

Javascript length variable displaying zero

can you please look at the image below and let me know what would lead to this?
The console shows that the variable playIcons has 3 items in it’s array.
then I’m declaring x = playIcons.length. (FYI – I tested it with several other variable names to make sure that the name wasn’t causing the issue.)
However x generates as zero, but when I put playIcons.length I receive the correct total. (3). Also, FYI, this is global.(not inside of a function)

Please let me know what leads to this so I can avoid it going forward.enter image description here