Filter and find properties in array of objects

This code is working but i would like to make it with array methods. The condition of filtering is: if programParent is empty string -> must pass, if id equals to some programParent -> must pass. I was trying to make it with filter method and find, but i need some help. Thanks in advance.

let programsRes = [
    { id: '23', name: 'ventas', programParent: '' },
    { id: '24', name: 'ventas OUT Personal', programParent: '23' },
    { id: '25', name: 'ventas OUT Personal plus', programParent: '24' },
    { id: '26', name: 'ventas IN Hogares', programParent: '23' },
    { id: '27', name: 'Ad Hoc', programParent: '' },
    { id: '28', name: 'Ad Hoc asd', programParent: '27' },
    { id: '29', name: 'Ad Hoc 123', programParent: '27' },
    { id: '30', name: 'ventas IN Personal plus', programParent: '26' },
]   

let expected = [
    { id: '23', name: 'ventas', programParent: '' },
    { id: '24', name: 'ventas OUT Personal', programParent: '23' },
    { id: '26', name: 'ventas IN Hogares', programParent: '23' },
    { id: '27', name: 'Ad Hoc', programParent: '' },
]


let result = []
for (let i = 0; i < programsRes.length; i++) {
    for (let j = 0; j < programsRes.length; j++) {
        if (programsRes[i].programParent === '') {
            result.push(programsRes[i])
            break;
        }
        if (programsRes[i].id === programsRes[j].programParent) {         
            result.push(programsRes[i])  
            break;
        }
    }
}
console.log(result)

How to alert when unload page while checking whether each element is changed or not

I developed page in which multiple input and textarea exist.
I would like to set unload event to prevent what we inputed are not inserted.

To set this,I also add checking whether each input elements are changed.

If text are changed. I would like to set this alert system.
while these texts are not changed, we can easily leave page and unload event will not be fired.

I have tried following . I would like to combile window.addEventListener('beforeunload') and window.addEventListener('load'). are there any good ways to achieve this?

My point is how to handle beforeUnloadAlert variables..

Thanks

window.addEventListener('beforeunload', function(e) {
    e.returnValue = 'Are you sure you want to exit?';
}, false);

window.addEventListener('load', function (e) {
    let beforeUnloadAlert = true;
    var inputs = document.querySelectorAll('.inputForm');

    for (var i = inputs.length - 1; i >= 0; i--) {
        inputs[i].addEventListener('change', displayName);
    }
    
    function displayName(e) {
        console.log(this);
        beforeUnloadAlert = false;
    }
    return beforeUnloadAlert
});
<input class='inputForm'>
<input class='inputForm'>
<input class='inputForm'>
<input class='inputForm'>

How do I get my cards to swap places in this poker game?

I’m working on a final project for my College Javascript class, the project is to call an API, https://deckofcardsapi.com/, and build a simple poker game that keeps score. I’ve been stuck on the part where I can select the cards I want to get rid of and swap in new cards from the deck for almost two days. My program so far does,

  1. init call of the deck from the API and sets deck ID
  2. Selects first five cards from the shuffled deck and builds them on the page
  3. Detects when you check the cards check box and puts them in a new array
  4. Calls new cards from the shuffled deck to replace the checked ones.
  5. Here is where I am stuck. The checkCards function is wrong somehow and maybe the newCard function as well.

Can anyone point me in the right direction?

`

`
let deckID = '';
let deck = '';
let deckHand = [];
let CardPanel = document.getElementById('cardPanel');
let Suit = '';
let Value = '';
let Pic = '';
let Code = '';
let card1 = deckHand[0];
let card2 = deckHand[1];
let card3 = deckHand[2];
let card4 = deckHand[3];
let card5 = deckHand[4];
let cards = [card1, card2, card3, card4, card5];
let selectedCardCodes = [];
let matched = [];
const gameBtn = document.getElementById('gameBtn');
const playCard = document.getElementById('drawCard');
let cardNum = 0;

//calls initial deck and sets the deck ID
function initCall() {
fetch('https://deckofcardsapi.com/api/deck/new/shuffle/')
.then(response => response.json())
.then((data) => {
//console.log(data.deck_id);
deckID = data.deck_id;
return data;
})
}

initCall();

// Starts game and builds and loads first five cards
gameBtn.addEventListener('click', () => {
fetch(`https://deckofcardsapi.com/api/deck/${deckID}/draw/?count=5`)
.then(response => response.json())
.then((data) => {
//deck = deckID;
console.log(data);
console.log(deckID);
for (let card = 0; card < data.cards.length; card++) {
deckHand.push(data.cards[card]);
deck = deckHand;
}
card1 = deckHand[0];
card2 = deckHand[1];
card3 = deckHand[2];
card4 = deckHand[3];
card5 = deckHand[4];
// Display Cards on page
cards = [card1, card2, card3, card4, card5];
//let cardNum = 1;

            for (const card of cards) {
    
                let cardDiv = buildCard(card);
    
                document.querySelector('#cardPanel').appendChild(cardDiv);
    
            }
            //return cards;
            //console.log(cards);
    
        })
        .catch(error => console.log(error))
    //)

})

function buildCard(card) {

    let cardDiv = document.createElement("div");
    cardDiv.setAttribute('id', `card${cardNum}`);
    let cardImg = `<img src="${card.image}" style="display: block">`;
    let cardName = `${card.value} OF ${card.suit} || `;
    let checkbox = document.createElement('input');
    checkbox.type = "checkbox";
    checkbox.setAttribute('id', `check${cardNum}`);
    checkbox.setAttribute('class', 'checkbox');
    checkbox.addEventListener('change', () => {
        console.log('Card selected', card);
        if (checkbox.checked) {
            selectedCardCodes.push(card);
        } else {
            // selected cards.remove card
            selectedCardCodes = selectedCardCodes.filter((c) => {
                return c.code !== card.code
            });
        }
    
        console.log(selectedCardCodes);
    })
    
    //console.log(cardNum);
    cardDiv.insertAdjacentHTML("afterbegin", cardImg);
    cardDiv.append(cardName);
    cardDiv.append(checkbox);
    
    cardNum++;
    return cardDiv;

}

async function newCard() {

    fetch(`https://deckofcardsapi.com/api/deck/${deckID}/draw/?count=1`)
        .then(response => response.json())
        .then((data) => {
            //deck = deckID;
            console.log(data);
            //console.log(deckID);
            for (let card = 0; card < data.cards.length; card++) {
                card = data.cards[card];
                return card;
                // deckHand.push(data.cards[card]);
                // deck = deckHand;
                // return cards[card];
            }
    
        })

}

async function checkCards(cards, selectedCardCodes) {

    matched = selectedCardCodes.filter((m) => {
        return cards.code === selectedCardCodes.code;
    })
    
    for (const card of matched) {
        let replacement = newCard();
        replacement = cards.splice(card, 1, replacement);
        return replacement;
    
    }
    
    //console.log(matched);

}

// Get card from API and add to array
playCard.addEventListener('click', async () => {

// remove selected cards from cards array
// draw n# of new cards
// add new cards to card array
// remove selected cards from array and reset array
// remove card array from DOM and redraw card array

})

`

I’ve tried splice, push and pop, and filter.

make new array of objects out of flat object with numbers in keys

Given this object:

const data = {
    home_tabs: 2,
    home_tabs_0_tab_alignment: "left",
    home_tabs_0_tab_content: "<h1>hello world</h1>",
    home_tabs_0_tab_cta: {
        title: 'Learn More',
        url: 'https://',
        target: ''},
    home_tabs_0_tab_icon:"fa-brands",
    home_tabs_0_tab_image: 473,
    home_tabs_0_tab_title:"Facebook",
    home_tabs_1_tab_alignment: "right",
    home_tabs_1_tab_content: "<h1>new world</h2>",
    home_tabs_1_tab_cta: {
        title: 'Learn More',
        url: 'https://',
        target: ''},
    home_tabs_1_tab_icon:"fa-brands",
    home_tabs_1_tab_image:851,
    home_tabs_1_tab_title:"Twitter"
}

How would I be able to remap it to something like this?

const home_tabs_array = [
  {
    image_alignment: 'left',
    content: '<h1>hello world</h1>',
    cta: {
      title: 'Learn More',
      url: 'https://',
      target: '',
    },
    icon: 'fa-brands',
    image: 851,
    title: 'Facebook',
  },
  {
    image_alignment: 'right',
    content: '<h1>new world</h2>',
    cta: {
      title: 'Learn More',
      url: 'https://',
      target: '',
    },
    icon: 'fa-brands',
    image: 473,
    title: 'Twitter',
  },
];

My current attempt is something like this:

const count = props.home_tabs;

let home_tabs_array = [];
// loop through the number of tabs
for (let i = 0; i < count; i++) {
  // create an object for each tab
  const tab = {
    image_alignment: props.home_tabs_[i]_image_alignment,
    content: props.home_tabs_[i]_content,
    cta: {
      title: props.home_tabs_[i]_cta_title,
      url: props.home_tabs_[i]_cta_url,
      target: props.home_tabs_[i]_cta_target,
    },
    icon: props.home_tabs_[i]_icon,
    image: props.home_tabs_[i]_image,
    title: props.home_tabs_[i]_title,
  };
  // push the object to the array
  home_tabs_array.push(tab);
}

But that’s a no go b/c of the []. But I don’t know how to access the number in the middle of the key.

Maybe I’m even looking at this the wrong way? How to access the number inside the key of the incoming object?

Managing configs for client-side npm modules – is there a preferred/standard way to go about this?

My primary question is whether or not the ‘config’ should be in a separate JSON/rc format, or if a general withCustomConfig-like function makes more sense. I realize this may be a matter of opinion, but I’m interested in hearing what more experienced developers think, as my searches for more information on this topic are coming up completely empty and I’m sure there’s a preferred/standard way of handling something like this.

Essentially, I’m building an npm package for the generation/parsing of markdown for a specific use-case. The package allows for custom configurations to the characters utilized in the structure of the markdown itself. Originally, I was just intending on having users apply changes to the config via a simple withCustomConfig function (that accepts a config object); however, I started wondering if setting it via a JS function was not ideal – as the config’s state then generally appears to seem more transient/loosely-defined than a completely separate rc or JSON config. I realize that is a matter of perception, but I think many people would share the same sentiment. And this poses a large risk because any changes to the configuration post-production would result in existing markdown becoming unparseable.

So, I started looking into having users configure a separate JSON config file. In order to import that into the browser, I realized I’d have to parse the JSON and convert it into a JS module before the user builds their client side application, which was relatively easy thanks to packages like fs. I set-up a small CLI utility to regenerate the JS module and added a postinstall script which parses the config file.

Then I started wondering if I was over-engineering this library, considering it’s bound to be a relatively small aspect in its users’ application. I started wondering if it even really warranted a completely separate config file and all the logic associated with parsing that for the browser. In general, would a simple withCustomConfig function actually be preferred/more-standard, or would an rc file be preferred by most people in this use case?

Emit events in the main vue 3 js

We are using vue 3 to create an app. We have 2 components in the main app. How can we maje the 2 components communicate with each other? How can we make the 2 components send or emit events?

const app = createApp({});

app.component('component1', Component1);
app.component('component2', Component2);

app.mount('#app');

Any help would be appreciated.

JQuery: Pushing attribute value to two different arrays based on radio options selected

In short, if a user selects yes to a radio option, I’m trying to obtain the data-name attribute from that input and push it to an array called accepted_array.

If a user selects no, then store data-name to declined_array.

Here is a visual to the markup:

<!-- options for John -->

<div class="guest__options-group">
  <input id="attending-yes-0" type="radio" name="attendance-0" value="yes" data-name="John" required />
  <label for="attending-yes-0">Yes</label>
</div>

<div class="guest__options-group">
  <input id="attending-no-0" type="radio" name="attendance-0" value="no" data-name="John" required />
  <label for="attending-no-0">No</label>
</div>

<!-- options for Alex -->

<div class="guest__options-group">
  <input id="attending-yes-1" type="radio" name="attendance-1" value="yes" data-name="Alex" required />
  <label for="attending-yes-1">Yes</label>
</div>

<div class="guest__options-group">
  <input id="attending-no-1" type="radio" name="attendance-1" value="no" data-name="Alex" required />
  <label for="attending-no-1">No</label>
</div>

Here are 2 approaches I’ve experimented with:

1.

(function ($) {

  $( ".guest__attendance-input" ).each(function(index) {
    $(this).on("click", function(){

      var $this = $(this);
      var checkedVal = $this.val();
      var accepted_array = [];
      var declined_array = [];

      if( checkedVal == "yes" ) {
        var name = $this.data("name");
        accepted_array.push(name);
      } else {
        declined_array.push(name);
      }

      console.log("accepted " + accepted_array.join(","));
      console.log("declined " + accepted_array.join(","));

    });

  });

}) (jQuery);

This only executes for the selected user and adds the name to both arrays.

2.

(function ($) {

  $( ".guest__attendance-input" ).each(function(index) {
    $(this).on("click", function(){

      var $this = $(this);
      var data = [];
      var checked = $this.is(':checked');
      var name = $this.attr('data-name');
      
      if (checked) {
        if (!data[name]) {
          data[name] = []
        }
        data[name].push($this.val())
      }
      console.log(data);
    });

  });

}) (jQuery);

Which only adds the user to a single array.

If both select yes, I need both names in the accepted_array. If someone selects yes initially and then selects no I need to remove them from the accepted_array and vice versa.

Creating multiple iframes to make a curved plane with synced iframes

I’m attempting to create a curved iframe. I know it is not possible to curve an iframe, although I have been researching and found a possible solution, which is, creating multiple iframes and later on syncing them.

I have got some of the code from this post: Three js curved (bend) CSS3DObject which served me really well, although I can’t seem to curve the frames and position them correctly.

Here is the fiddle I have created:
https://jsfiddle.net/niltonsf/2cwq38tb/1/

var scene, camera, renderer, container;

init();
animate();

function init() {

  scene = new THREE.Scene();
  var  createElements= function(url, divisions, parent) {
    var w = 100.0 / divisions;
    var x = 0;

    for (var x = 0; x < 100; x += w) {
      var el = document.createElement('iframe');
      el.src = url;
      var x2 = x + w;
      el.style = "clip-path:polygon(" + x + "% 0%, " + x2 + "% 0%, " + x2 + "% 100%, " + x + "% 100%);";
      var cssObject = new THREE.CSS3DObject(el);
/*       if (x > 90){
      cssObject.rotation.y = x * 0.4
      console.log(x*-1)
              cssObject.position.z = x * -1
      } else {
        cssObject.position.z = x * 1
      }
       */      
       if (x >= 95 || x <= 1) {
        /* cssObject.position.z = 0 */
       } else if (x > 60) {
        cssObject.position.z = (x * -1) * 1 + 10
       } else {
       cssObject.position.z = x * -1
       }
      parent.add(cssObject);
    }
  }
    container = new THREE.Object3D();
  createElements("https://example.com/",24,container);
    scene.add(container);
  camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 10000);
  camera.position.z = 200;
  camera.position.y = 30;
  renderer = new THREE.CSS3DRenderer();
  renderer.setSize(window.innerWidth, window.innerHeight);

  document.body.appendChild(renderer.domElement);

}

function animate() {
container.rotation.y += .005;

  requestAnimationFrame(animate);
  

  renderer.render(scene, camera);

}

enter image description here

As you can see in the image, the red and aqua circles are referring to the ends of the plane bend, the frames from the red circle on (until the middle of all frames) should go backwards until the green circle. On the green circle on the frames should go positive back to the aqua circle, achieving something like:
enter image description here

JAVASCRIPT will not update array outside loop

my problem is the following. Javascript seems to not update the values in arr_root in the loop ‘for (let y = 0; y < 2; y++)’.
The values of that remains the same,

  console.log("INSIDE: arr_root: " + arr_root);

even if:

  console.log("OUT: arr_root: " + arr_root);

Show’s the updated values at the end of the loop.

The function should find the overlapping characters in order from root in word.
So the resulting array ‘overlaps’ should be [‘e’, ‘ice’] and not [‘e’, ‘e’] whit input

  var word = "ice";
  var root = "device";

findWordPattern();

function findWordPattern() {
  var overlap_number = 0;
  var is_partial = false;
  var overlaping_charaters = [];
  var overlaps = [];
  var after_last_letter_found_pos = 0;
  var positions_to_delete_from_root = [];

  var word = "ice";
  var root = "device";

  //Split string into arrays
  var arr_word = word.split("");
  var arr_root = root.split("");
  console.log("ORIGINAL arr_word: " + arr_word);
  console.log("ORIGINAL arr_root: " + arr_root);

  for (let y = 0; y < 2; y++) {
    console.log("INSIDE: arr_word: " + arr_word);
    console.log("INSIDE: arr_root: " + arr_root);

    for (let i = 0; i < arr_root.length; i++) {
      for (let j = after_last_letter_found_pos; j < arr_word.length; j++) {
        if (arr_root[i] === arr_word[j]) {
          overlap_number++;
          overlaping_charaters.push(arr_root[i]);

          //changin j pos to look only after the first found letter, instead of re-itererating the wole array
          after_last_letter_found_pos = j + 1;
          positions_to_delete_from_root.push(i);
          break;
        }
      }
    }

    overlaps.push(overlaping_charaters);
    console.log("array overlaps: ");
    console.log(overlaps);

    //removing overlapping char from root
    for (let i = 0; i < positions_to_delete_from_root.length; i++) {
      console.log(
        "deleting " + arr_root[positions_to_delete_from_root[i]] + " from root"
      );
      arr_root.splice(positions_to_delete_from_root[i], 1);
      console.log("arr_root after splice: " + arr_root);
    }
    //resetting positions_to_delete_from_root
    positions_to_delete_from_root = [];
  }

  console.log("OUT: arr_word: " + arr_word);
  console.log("OUT: arr_root: " + arr_root);

  var longest = overlaps.sort(function(a, b) {
    return b.length - a.length;
  })[0];


  console.log({
    word: word,
    root: root,
    overlaping_charaters: longest,
    overlap_number: overlap_number,
    is_partial: is_partial
  });

  return {
    word1: word,
    root: root,
    overlaping_charaters: longest,
    overlap_number: overlap_number,
    is_partial: is_partial
  };
}

As I’ve already said the expred result in ‘overlaps’ should be [‘e’, ‘ice’] and not [‘e’, ‘e’].
I’ve tried to create another variable in the for(y=0 ….) but it didn’t change anything.
Other variables are updated outside of the loop.

How to compare objects in single array and give validation based on previous object value

I have one array which has n number of objects, suppose if I was having 3 objects, and the value of one property at index 1 is null then the value for the same property is having value in next index it should show error that previous object value shouldn’t be blank

Example sample:[{Id:1, name:’abc’}, {id:2, name:”}, {id:3, name:’dcg’}]
Here based on iteration as name is empty at index 1 and having value for name at index 2 it should throw error previous object value name cannot be blank. How to achieve this using forEach

TypeScript Date type is not JS Date type?

I have a model:

export class SendModel{
periodFrom: Date,
periodTo: Date
}

I have a service:

public async Calculate(periodFrom: Date,  periodTo: Date):Promise<SendModel>
{
let resObj = this.http.get(url, params:{periodFrom: `${periodFrom}`, periodTo: `${periodTo}`}).toPromise();
//...another code...//
}

I receive a SendModel object from api.

{
periodFrom: '2022-11-24T00-00-00Z',
periodTo: '2026-01-01T00-00-00Z'
}

Ok, I need add 3 month to periodFrom var.

let startPayday = receiveObj.periodFrom.setMonth(receiveObj.periodFrom.getMonth()+3); //not working, despite receiveObj.periodFrom has type is Date (what?)
let startPayday2 = new Date(new Date(receiveObj.periodFrom).setMonth(new Date(receiveObj.periodFrom).getMonth()+3)); //worsk! ok

Ok, let`s send it to api.

this.service.Calculate(startPayday2, receiveObj.periodTo); //error!

Wrong api call, status 400, One or more validation errors.
Look at the request: api/calculate?periodFrom=Fri Feb 24 2023 03:00:00 GMT 0300 (blablabla)&periodTo=2026-01-01T00-00-00Z

Maybe like this?

this.service.Calculate(startPayday2.toISOString(), receiveObj.periodTo); //nope, argument is type 'string' bla-bal-bla...

startPayday2 has type Date, API expects type Date, but these are different types that are serialized differently?

POST method not working via JavaScript (OK, via form submission with button)

The “/” route renders “form1.ejs”, this file contains an HTML dropdown box. When a change is detected within the dropdown, it triggers the execution of a function which perform a POST to route “/form”, which then redirects to GET route “/form2” which is then supposed to render “form2.ejs”. It appears that the POST worked because a console.log seems to confirm it, with “About to redirect to “/form2″”, which seems to occur, because inside this GET route, two more console.logs are triggered, except that the browser does not show the GET route as “/form2” it still says “/form1” and the “form2.ejs” is not rendered.

If I were to manually enter the “/form2” route by typing it into the browser URL, the browser then displays “form2.ejs”, as expected (along with the “/form2” route. Also, to test the routing, I added a submit button to the form in “form1.ejs”, and when I click on submit, the POST occurs fine, it redirects to the GET and “form2.ejs” is rendered.

So in summary, I can make a POST request via the button and receive the expected chain of events, but not so, when executing a POST via JavaScript … even though the console.log(s) appear to indicate that all routes along the chain were triggered.

For those curious enough to want to reproduce:
https://github.com/timholmez/POST-using-JavaScript

app.js

let http = require('http');
const path = require('path');
const bodyParser = require('body-parser')
const session = require('express-session');

let express = require('express');
var jsonParser = bodyParser.json();
let app = express();
let http_port = 8080;
let httpServer = http.createServer(app);

httpServer.listen(http_port, () => {
    console.log(`Listenting on Port:${http_port}`);
});

app.use(express.static(`public`));
app.use(express.urlencoded({ extended: true}));

const sessionConfig = {
    secret: `notagoodsecret`,
    resave:false,
    saveUninitialized: false,
    cookie: {
        httpOnly: true,
        expires: Date.now() + 1000 * 60 * 60 * 24, // 24 hours
        maxAge: 1000 * 60 * 60 * 24
    }
}
app.use(session(sessionConfig));

app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');

app.get('/', function (req, res) {
    res.render('form1');
});

app.post('/form', jsonParser, (req, res) => {
    req.session.action = JSON.stringify(req.body.action);
    console.log(`About to redirect to "/form2"`);
    res.redirect(`/form2`);
});

app.get(`/form2`, (req, res) => {
    console.log(`Inside The "/form2" Route`);
    const action = req.session.action
    console.log(`Action:${req.session.action}`);
    res.render(`form2`, {action})
});

form1.ejs

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
  </head>
<body>

<script type="text/javascript">

  async function postData(url, data) {
    console.log(`postData got called within form1.ejs`);
    const response = await fetch(url, {
      method: 'POST',
      body: JSON.stringify(data),
      headers: {'Content-type': 'application/json; charset=UTF-8'}
    })
      .then(response => {
          if (!response.ok) {
              throw new Error("Could not reach desired route.");
          }
          return response.text();
      })

      .catch((err) => {
        console.log(`Error Occured Executing function "postData"`);
        console.error(err);
      })
  }

  function firstAction(dropdown) {
    var optionValue = dropdown.options[dropdown.selectedIndex].value;
    const data = {"action": optionValue}

    postData('/form', data)
  }
</script>

<div>
  <h1>This is Form 1</h1>
  <form action="/form" method="POST">
    <label for="action">Action</label>
    <select onchange="firstAction(this)" name="action" id="action">
      <option value = "item1">Item 1</option>
      <option value = "item2">Item 2</option>
      <option value = "item3">Item 3</option>
      <option value = "item4">Item 4</option>
      <option value = "item5">Item 5</option>
    </select>
    <button type="submit">Submit</button>
  </form>
</div>

</body>
</html>

form2.ejs

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
  </head>
<body>
<div>
  <h1>This is Form 2 and it only displays if the POST request is submitted via the button
    from within the form. The POST request made via javascript does not accomplish the
    same even though the /form2 "GET" route appears to have been activated as evidenced
    by the console.log messages that are triggered whilst in route /form2"</h1>
</div>
</body>
</html>

Any thoughts anyone?
Thanks.
Tim.

Get Discord bot to join when a user joins then leaves after sound is played

I’m trying to get the Discord bot to join when a specific user joins. The bot shows online in the Discord server but isn’t joining when I join. Is there a way the username has to be formatted or am I missing something?

I thought it was the username missing the # tag for the username but that didn’t produce any results.

console.log('On');
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({ 
  intents: [
    GatewayIntentBits.GuildVoiceStates
  
  ]

});

client.on('voiceStateUpdate', (oldState, newState) => {
// check if the user who joined is the specific user we want
if (newState.member.id === 'SteveT') {
// check if the user joined a voice channel
if (newState.channel) {
// play the specific sound
newState.channel.join().then(connection => {
const dispatcher = connection.play('C:UsersstorrMusicbotsounds');
dispatcher.on('finish', () => {
// leave the voice channel after the sound is played
newState.channel.leave();
});
});
}
}
});

  client.login('insertbotkey');

Covert Java String Class to array in Javascript

I have the following string class return back from a java call as below:

[ABC, DEF, GHI, JKL]

When I trying to print it out within JavaScript, it’s showing me the following code:

[Ljava.lang.String;@60d69971

I just wandering, will it be possible for me to convert this output to array format in JavaScript? So that I can applied the indexOf() to find out the index of each string within the string class.