Labeling of parameters within function to pull arguments from rest parameter

I’m working my way through the Odin Project and have a simple question about rest parameters:

One of the tutorial asks to ‘Implement a function that takes an array and some other arguments then removes the other arguments from that array:’ and the solution they provide is below

I understand the arguments[0] bit pulls out the first argument from …args, but does the ‘val’ parameter just work to pull any additional arguments from …args? no matter how many other arguments after the first?

const removeFromArray = function(...args) {
    const array = arguments[0];
    return array.filter((val) => !args.includes(val));
};

Vue Js: count number is not resetting to zero

in my code below, i have set a counter to notification in sidebar and i created a component in app.vue to pass the number and counter as well to sidebar … the count number works good and i’m getting number updated whenever a new notification received, but i wanted to set count back to zero when i click on the notification icon but it didn’t work.
below i passed function onReset by using emit but it’s not accessing function and i can’t even see my console.log inside the function

am i doing something wrong here? please help

//app.vue

<template>
  
<router-view :number="count" @send="getNewCount">

<sidebar :number="count" @reset="onReset" />

</router-view>
</template>

<script>
// @ts-ignore
import sidebar from "@/views/Layout/DashboardLayout.vue";
import axios from "axios";
import {
    io
} from "socket.io-client";

let socket = io("h*****.com/");
export default {
components: {
    sidebar,


  },
    data() {
        return {
            user2: JSON.parse(sessionStorage.getItem("user")),
            count: 0,
            today: null,
            
        };
        
    },
       props: {
    number: {
      type: Number,
      default: 0,
    },},
    async created() {
        console.log(this.count);
        const response = await axios.get(
            `*******api/${this.user2._id}/`, {
                headers: {
                    Authorization: "Bearer " + sessionStorage.getItem("user"),
                },
            }
        );



        socket.emit("user_connected", this.user2.username);
        // console.log(this.user2,"userr")
        socket.on("verify_connection", (data) => {
            this.verify_connection = data;
            console.log(data, "s")
        });

        socket.emit("user_connected", this.user2.username);
        socket.on("verify_connection", (data) => {
            console.log("heyy", data);
            this.verify_connection = data;
        });
        socket.on("updated_flat", (data) => {

            console.log("heyy", data);
            this.makeToast(" success ", "'b-toaster-top-center");

     

        });
        socket.on("test", (data) => {

            console.log("heyy", data);
  

          

        });

        ;
    },

    methods: {
  
        getNewCount(data) {
            this.count = data;
        },
           onReset() { //not working
      // api calls, etc.
     this.count = 0;
     console.log(this.count,"reser")
    },
        makeToast(variant = null, toaster, append = false) {
            this.$bvToast.toast(" edited ", {
                title: "BootstrapVue Toast",
                variant: variant,
                autoHideDelay: 10000,
                toaster: toaster,
                position: "top-right",

                appendToast: append,
            });
            // this.playSound();
            this.count = this.count + 1;
                console.log(this.count,"count");
        },

    },

}
</script>
//sidebar.vue

<sidebar-item v-if="roles ==='Admin'" 
 
                  :link="{ 
                    name: ' notification',
                    path: '/notifications',
                    icon: 'ni ni-bell-55 text-green'
                  }">  
               
          
        </sidebar-item>
   
<p class="notifCount" v-if="roles ==='Admin'"  @click="$emit('reset')">  {{ number }}  </p> //not working

Adding subcommands to interaction discord.js v13

I am trying to make a discord bot with / commands. I already got a lot working, but if I try to use subcommands it doesnt work. I followed the discordjs guide, even completely copying it doesnt work. I use the event handler and the command handler from the guide. I get the error:

TypeError: command.execute is not a function

index.js code:

console.clear();

const fs = require('fs');
const { Client, Collection ,Intents } = require('discord.js');
const { token } = require('./config.json');

const client = new Client({ intents: [Intents.FLAGS.GUILDS] });

const eventFiles = fs.readdirSync('./events').filter(file => file.endsWith('js'));

for (const file of eventFiles) {
    const event = require(`./events/${file}`);
    if(event.once) {
        client.once(event.name, (...args) => event.execute(...args));
    } else {
        client.on(event.name, (...args) => event.execute(...args))
    }
}

client.commands = new Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));

for (const file of commandFiles) {
    const command = require(`./commands/${file}`);
    // Set a new item in the collection
    // With the key as the command name and the value as the exported module
    client.commands.set(command.data.name, command);
}



client.on('interactionCreate', async interaction => {
    if (!interaction.isCommand()) return;

    const command = client.commands.get(interaction.commandName);

    if(!command) return;

    try {
        await command.execute(interaction);
    } catch (error) {
        console.error(error);
        await interaction.reply({ content: 'There was an error while executing this command', ephemeral: true});
    }
});

client.login(token)

info.js code:

const { SlashCommandBuilder } = require('@discordjs/builders');

module.exports = {
    data: new SlashCommandBuilder()
        .setName('info')
        .setDescription('Get info about a user or the server!')
        .addSubcommand(subcommand =>
            subcommand
                .setName('user')
                .setDescription('Info about a user')
                .addUserOption(option => option.setName('target').setDescription('The user')))
        .addSubcommand(subcommand =>
            subcommand
                .setName('server')
                .setDescription('Info about the server')),
    async exexute(interaction) {
        if (interaction.options.getSubcommand() === 'user') {
            const user = interaction.options.getUser('target');

            if (user) {
                await interaction.reply(`Username: ${user.username}nID: ${user.id}`);
            } else {
                await interaction.reply(`Your username: ${interaction.user.username}nYour ID: ${interaction.user.id}`);
            }
        } else if (interaction.options.getSubcommand() === 'server') {
            await interaction.reply(`Server name: ${interaction.guild.name}nTotal members: ${interaction.guild.memberCount}`);
        }
    }
}

Command handler “require is not a function” error (JavaScript)

client.events = new Discord.Collection();
['event_handler', 'command_handler'].forEach(handler =>{
    require(`./handlers/${handler}`)(client, Discord);
})

Have that, and for some reason the console says “require is not a function”. Error right below:

    require(`./handlers/${handler}`)(client, Discord);
                                    ^

TypeError: require(...) is not a function

What can I do to fix this? I tried everything I could but no luck.

Array from data base returing undefined,

Mark up

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">   
    <script src="https://cdn.tailwindcss.com"></script>
      
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jdenticon.min.js" integrity="sha384-l0/0sn63N3mskDgRYJZA6Mogihu0VY3CusdLMiwpJ9LFPklOARUcOiWEIGGmFELx"
        crossorigin="anonymous"></script>

    <script src="https://www.gstatic.com/firebasejs/8.8.1/firebase-app.js"></script>
    <script src="https://www.gstatic.com/firebasejs/8.8.1/firebase-analytics.js"></script>
    <script src="https://www.gstatic.com/firebasejs/8.8.1/firebase-firestore.js"></script>
    <script src="./firebase.js"></script>
    
    <script src="./header.js"></script>
  
    <link rel="stylesheet" href="style.css">
    <title>amazon 2.0</title>
</head>
<body  class="text-blue-900">
    <div class="bg-white w-full">




        <!-- Header -->
        <div class="header bg-gray-900 flex items-center">
            <div class="logo w-1/5 h-16 ml-10">
               <img class="w-28 h-16 object-contain" src="https://www.pinclipart.com/picdir/big/57-576184_view-our-amazon-storefront-amazon-logo-white-png.png" alt="imageNotFound">
            </div>



            <!-- Search Bar -->
            <input class="w-30 h-9 bg-gray-800 border border-gray-500 border-opacity-75 rounded-l-xl px-3 text-white ml-6 focus:outline-none placeholder-white" type="text" id="search" placeholder = "Search...">



            <!-- Categories dropdown -->
            <div class="categories h-9 w-30 bg-gray-800 border border-gray-500 border-opacity-75 text-white flex items-center px-3">
                categories <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 ml-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
                  </svg>
            </div>



            <!-- search icon -->
            <div class="search-icon h-9 w-10 bg-yellow-500 rounded-r-xl flex items-center justify-center text-white">
                <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
                  </svg>
            </div>

            <!-- Right icons -->
            <div class="icons text-white flex items-center ml-auto mr-8 w-48 h-16 justify-around">

                <!-- heart icon -->
                <svg class="h-4 w-4" xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z" />
                  </svg>

                  <!-- Cart icon -->
                  <a href="cart.html">
                    <div class="cart-icon h-10 w-10 bg-yellow-500 rounded-xl flex justify-center items-center text-xs text-gray-600 relative">
                        <div class="cart-item-number absolute -top-1 -right-1 h-4 w-4 rounded-full bg-white flex justify-center items-center text-black">1</div>
                      <svg class = "h-4 w-4"xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                          <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 3h2l.4 2M7 13h10l4-8H5.4M7 13L5.4 5M7 13l-2.293 2.293c-.63.63-.184 1.707.707 1.707H17m0 0a2 2 0 100 4 2 2 0 000-4zm-8 2a2 2 0 11-4 0 2 2 0 014 0z" />
                        </svg>
                    </div>
                  </a>

                  <!-- bell icon -->
                  <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9" />
                  </svg>


                  <svg class=" rounded h-12 w-12" width="80" height="80" data-jdenticon-value="Abdullah"></svg>

            </div>




        </div>

        <!-- Main section -->
        <div class="main h-screen flex bg-gray-100">

            <!-- Left hand side bar -->
            <div class="main-sidebar w-1/5 h- bg-gray-900 border-gray-700 border-t-2 p-6 ">

                <!-- Child categories bar for optimal padding -->
                <div class="sidebar-categories">

                    <!-- The Categories button -->
                    <div class="text-yellow-500 cursor-pointer flex mb-3 p-2 bg-gray-700 rounded-lg font-bold">

                        <!-- Grid icon -->
                        <span class="w-8">
                        <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z" />                        
                      </svg>
                    </span>

                    <!-- Text -->
                      <span>Categories</span>
                    </div>

                    <div class="side-bar-main-category text-white cursor-pointer flex p-2 mb-2 ">
                        <span class="w-8"></span>
                        <span>Echo and alexa</span>
                    </div>
                    <div class="side-bar-main-category text-white cursor-pointer flex p-2 mb-2">
                        <span class="w-8"></span>
                        <span>Kindle</span>
                    </div>
                    <div class="side-bar-main-category text-white cursor-pointer flex p-2 mb-2">
                        <span class="w-8"></span>
                        <span>Books</span>
                    </div>
                    <div class="side-bar-main-category text-white cursor-pointer flex p-2 mb-2">
                        <span class="w-8"></span>
                        <span>Electronics</span>
                    </div>
                    <div class="side-bar-main-category text-white cursor-pointer flex p-2 mb-2">
                        <span class="w-8"></span>
                        <span>Home and Garden</span>
                    </div>
                    <div class="side-bar-main-category text-white cursor-pointer flex p-2 mb-2">
                        <span class="w-8"></span>
                        <span>Fashion</span>
                    </div>
                    <div class="side-bar-main-category text-white cursor-pointer flex p-2 mb-2 font-bold rounded-lg hover:bg-gray-700 mb-4">
                        <span class="w-8 flex justify-center items-center"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="percent" class="svg-inline--fa fa-percent w-4 h-4" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M112 224c61.9 0 112-50.1 112-112S173.9 0 112 0 0 50.1 0 112s50.1 112 112 112zm0-160c26.5 0 48 21.5 48 48s-21.5 48-48 48-48-21.5-48-48 21.5-48 48-48zm224 224c-61.9 0-112 50.1-112 112s50.1 112 112 112 112-50.1 112-112-50.1-112-112-112zm0 160c-26.5 0-48-21.5-48-48s21.5-48 48-48 48 21.5 48 48-21.5 48-48 48zM392.3.2l31.6-.1c19.4-.1 30.9 21.8 19.7 37.8L77.4 501.6a23.95 23.95 0 0 1-19.6 10.2l-33.4.1c-19.5 0-30.9-21.9-19.7-37.8l368-463.7C377.2 4 384.5.2 392.3.2z"></path></svg></span>
                        <span>Sell on Amazon</span>
                    </div>
                    <div class="side-bar-main-category text-white cursor-pointer flex p-2 mb-2 font-bold rounded-lg hover:bg-gray-700">
                        <span class="w-8 flex ">
                            <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
                              </svg>
                        </span>
                        <span>Help</span>
                    </div>
                </div>
            </div>

            <!-- main section of cart -->
            <div class="main-section flex-1 p-6 bg-white">

                <!-- Heading -->
                <h1 class="text-gray-400 font-bold text-3xl mb-6">Shopping Cart</h1>


                <!-- headings of tables -->
                <div class="table-titles flex  font-bold text-gray-400">
                    <h2 class="flex-grow">Product</h2>
                    <h2 class="w-48">Count</h2>
                    <h2 class="w-48">Total Cost</h2>
                    <span class="w-10"></span>
                </div>

                <!-- cart items -->
                <div id = 'cart-items' class="cart-items this mt-5">
                    

                    <!--  -->
                    <div class="cart-item flex items-center pb-4 border-b border-gray-100">
                        <!-- Product img -->
                        <div class="cart-item-image w-40 h-24 bg-white p-4 rounded-lg">
                            <img class="w-full h-full object-contain" src="https://pisces.bbystatic.com/image2/BestBuy_US/images/products/6418/6418603_sd.jpg" alt="">
                        </div>
                        
                        <!-- Product detail -->
                        <div class="cart-item-detail flex-grow">
                            <div class="cart-item-title font-bold text-sm text-gray-600">Apple MacBook pro 13,3</div>
                            <div class="cart-item-brand  text-sm text-gray-400">
                                Apple
                            </div>
                        </div>
    
    
                        <div class="cart-item-counter w-48 flex items-center">

                            <!-- Left chrvron -->
                            <div class="chevron-left cursor-pointer text-gray-400 bg-gray-100 rounded w-6 h-6 flex justify-center items-center hover:bg-gray-200 mr-2">
                                <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
                                    <path fill-rule="evenodd" d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z" clip-rule="evenodd" />
                                  </svg>
                            </div>

                            <!-- number of items -->
                            <h4 class="text-gray-400">x1</h4>


                            <!-- right chevron -->
                            <div class="chevron-right cursor-pointer text-gray-400 bg-gray-100 rounded w-6 h-6 flex justify-center items-center hover:bg-gray-200 ml-2">
                                <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
                                    <path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd" />
                                  </svg>
                            </div>
                        </div>
    
                        <!-- Product Price -->
                        <div class="cart-item-total-cost w-48 font-bold text-gray-400">
                            $1,149.00
    
                        </div>
    
                        <!-- Delete item icon -->
                        <div class="cart-item-delete w-10 font-bold text-gray-300 cursor-pointer hover:text-gray-400">
                            <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
                              </svg>
                        </div>
                    </div>


                    <!-- Second item -->
                    <div class="cart-item flex items-center pb-4 border-b border-gray-100">
                        <!-- Product img -->
                        <div class="cart-item-image w-40 h-24 bg-white p-4 rounded-lg">
                            <img class="w-full h-full object-contain" src="https://m.media-amazon.com/images/I/61-PblYntsL._AC_SL1500_.jpg" alt="">
                        </div>
                        
                        <!-- Product detail -->
                        <div class="cart-item-detail flex-grow">
                            <div class="cart-item-title font-bold text-sm text-gray-600">Nintendo Switch</div>
                            <div class="cart-item-brand  text-sm text-gray-400">
                                Nintendo
                            </div>
                        </div>
    
    
                        <div class="cart-item-counter w-48 flex items-center">

                            <!-- Left chrvron -->
                            <div class="chevron-left cursor-pointer text-gray-400 bg-gray-100 rounded w-6 h-6 flex justify-center items-center hover:bg-gray-200 mr-2">
                                <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
                                    <path fill-rule="evenodd" d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z" clip-rule="evenodd" />
                                  </svg>
                            </div>

                            <!-- number of items -->
                            <h4 class="text-gray-400">x1</h4>


                            <!-- right chevron -->
                            <div class="chevron-right cursor-pointer text-gray-400 bg-gray-100 rounded w-6 h-6 flex justify-center items-center hover:bg-gray-200 ml-2">
                                <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
                                    <path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd" />
                                  </svg>
                            </div>
                        </div>
    
                        <!-- Product Price -->
                        <div class="cart-item-total-cost w-48 font-bold text-gray-400">
                            $290.00
    
                        </div>
    
                        <!-- Delete item icon -->
                        <div class="cart-item-delete w-10 font-bold text-gray-300 cursor-pointer hover:text-gray-400">
                            <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
                              </svg>
                        </div>
                    </div>


                </div>

                <div class="complete-order flex justify-end mt-10">

                    <!-- total cost -->
                    <div class="total-cost mr-7">

                        <h2 class="text-gray-400">Total Cost</h2>
                        <div class="total-cost-number text-3xl font-bold text-gray-600">
                            $1,439.00
                        </div>
                    </div>
                    <div class="complete-order-button w-56 flex items-center justify-center bg-yellow-500 rounded text-white cursor-pointer hover:bg-yellow-600">
                        Complete Order
                    </div>

                </div>
            </div>

           
        </div>
    </div>
    <script src="./cart.js"></script>
</body>
</html>

Script

var firebaseConfig = {
  apiKey: "AIzaSyDJhP_i1oa9MUCAIrSsQosxuJIa3dkyouE",
  authDomain: "test-4ce90.firebaseapp.com",
  projectId: "test-4ce90",
  storageBucket: "test-4ce90.appspot.com",
  messagingSenderId: "524556826840",
  appId: "1:524556826840:web:8eb8c922aa49c10e397fad",
  measurementId: "G-6Z6PZF2X8W"
};

// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.analytics();

var db = firebase.firestore();

function getCartItem() {
  db.collection("cart-item")
    .onSnapshot((Snapshot) => {
      let totalCount = 0;

      Snapshot.forEach((doc) => {
        totalCount += doc.data().quantity;
      });
      setCartCounter(totalCount);
    });
}
getCartItem();
function setCartCounter(totalCount) {
  document.querySelector(".cart-item-number").innerText = totalCount;
}

    function getCartItems(){
        let cartItems = [];
        db.collection('cart-item').onSnapshot((snapshot)=>{
            snapshot.docs.forEach(doc => {
                cartItems.push({
                    id : doc.id,
                    ...doc.data()
                });
            });
        })
        generateCartItems(cartItems);
       
        console.log(cartItems)
    }
    
    
    function generateCartItems(cartItems){
        let itemHTML = "";
     
        cartItems.forEach((item) =>{
            console.log('Came in the loop');
            itemHTML +=`
            <div class="cart-item flex items-center pb-4 border-b border-gray-100">
                <!-- Product img -->
                <div class="cart-item-image w-40 h-24 bg-white p-4 rounded-lg">
                    <img class="w-full h-full object-contain" src="${item.image}" alt="">
                </div>
                
                <!-- Product detail -->
                <div class="cart-item-detail flex-grow">
                    <div class="cart-item-title font-bold text-sm text-gray-600">${item.name}</div>
                    <div class="cart-item-brand  text-sm text-gray-400">
                        ${item.make}
                    </div>
                </div>
    
    
                <div class="cart-item-counter w-48 flex items-center">
    
                    <!-- Left chrvron -->
                    <div class="chevron-left cursor-pointer text-gray-400 bg-gray-100 rounded w-6 h-6 flex justify-center items-center hover:bg-gray-200 mr-2">
                        <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
                            <path fill-rule="evenodd" d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z" clip-rule="evenodd" />
                          </svg>
                    </div>
    
                    <!-- number of items -->
                    <h4 class="text-gray-400">x${item.quantity}</h4>
    
    
                    <!-- right chevron -->
                    <div class="chevron-right cursor-pointer text-gray-400 bg-gray-100 rounded w-6 h-6 flex justify-center items-center hover:bg-gray-200 ml-2">
                        <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
                            <path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd" />
                          </svg>
                    </div>
                </div>
    
                <!-- Product Price -->
                <div class="cart-item-total-cost w-48 font-bold text-gray-400">
                    $${item.price*item.quantity}
    
                </div>
    
                <!-- Delete item icon -->
                <div class="cart-item-delete w-10 font-bold text-gray-300 cursor-pointer hover:text-gray-400">
                    <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
                      </svg>
                </div>
              
            `
        })
        document.querySelector('#cart-items').innerHTML = itemHTML;
    }
    
    getCartItems();

my javascript file I am Fetching data from firebase and pushing it one by one in an array. Now if i console log the whole array it show the whole array like normal as bellow
[H]Snapshot of Out put1

But as in generateCartItems() i loop it it wont happen and if i console log the array’s element it will show undefined Kindly tell what is the issue here Thankyou very much

try block is not getting executed when return a value in javascript

I am learning the try...catch statement in Javascript. While learning I have come to a problem where I am not understanding why the try block code is not getting executed along with the finally block when I return the values. Only finally block gets executed. But when I console the values, the try block gets executed along with finally block.

function test() {
  try {
    return "try block";
  } catch (error) {
    return "error block";
  } finally {
    return "finally block";
  }
}
console.log(test());

//output - 
finally block
function test() {
  try {
    console.log("try block")
  } catch (error) {
    console.log("error block", error)
  } finally {
    console.log("finally block")
  }
}
test()

//output - 
try block
finally block

Node Js EventEmitter is not listening events calling from another class

I have tried to pass an event from a class to another function, the emit event is not passing to that function.

App.js

const Logger = require('./logger');
const logger = new Logger();
logger.on('msgLoged', (arg) => {
   console.log("6. Listner called !!!", arg);
});

logger.js

const EventEmitter = require('events');
class Logger extends EventEmitter {
   log(message) {
       console.log(message);
       this.emit('msgLoged', {id: 1, data: "someathing"})
    }
}

Google Maps additional parameter to mouseover

I’m trying to pass an additional parameter to show in the mouseover event, but it’s only showing the last one.

tried passing the variable via addListener with stepDisplay.setContent but, don’t show nothing.

    var stepDisplay

    function initMap() {

      const directionsService = new google.maps.DirectionsService();

      map = new google.maps.Map(document.getElementById("map"), {
        center: {
          lat: -23.6085666,
          lng: -46.6663397
        },
        zoom: 12,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      });
      const directionsRenderer = new google.maps.DirectionsRenderer({
        map: map
      });

        for (var i = 0; i < polylines.length; i++) {
            polylines[i].setMap(null);
        }
      var listPos = [{"maps_latA":"-23.577084","maps_lonA":"-46.629042","maps_latB":"-23.611103","maps_lonB":"-46.655907", "display": "test1"},
      {"maps_latA":"-23.6039706","maps_lonA":"-46.6637391","maps_latB":"-23.606099","maps_lonB":"-46.668277", "display": "test2"}];

      for (var i = 0; i < listPos.length; i++) {

        var startPoint = new google.maps.LatLng(listPos[i]['maps_latA'], listPos[i]['maps_lonA']);
        var endPoint = new google.maps.LatLng(listPos[i]['maps_latB'], listPos[i]['maps_lonB']);

            stepDisplay = new google.maps.InfoWindow({
                content: listPos[i]['display']
            });

        var directionsDisplay = new google.maps.DirectionsRenderer({
          map: map,
          preserveViewport: false
        });

        calculateAndDisplayRoute(directionsDisplay, directionsService, stepDisplay, startPoint, endPoint);

      }

      map.fitBounds(flightPath.getBounds());
    }

    function calculateAndDisplayRoute(directionsDisplay, directionsService,
      stepDisplay, startPoint, endPoint) {
      directionsService.route({
        origin: startPoint,
        destination: endPoint,
        travelMode: 'DRIVING'
      }, function(response, status) {
        if (status === 'OK') {
          renderPolylines(response);
        } else {
          window.alert('Directions request failed due to ' + status);
        }
      });
    }
    var polylineOptions = {
      strokeColor: 'green',
      strokeOpacity: 1,
      strokeWeight: 4
    };
    var polylines = [];

    function renderPolylines(response) {
        var bounds = new google.maps.LatLngBounds();
        var legs = response.routes[0].legs;
        for (i = 0; i < legs.length; i++) {
            var steps = legs[i].steps;
            for (j = 0; j < steps.length; j++) {
                var nextSegment = steps[j].path;
                var stepPolyline = new google.maps.Polyline(polylineOptions);
                for (k = 0; k < nextSegment.length; k++) {
                    stepPolyline.getPath().push(nextSegment[k]);
                    bounds.extend(nextSegment[k]);
                }
                google.maps.event.addListener(stepPolyline, 'mouseover', function(evt) {
                    this.setOptions({
                        strokeWeight: 8
                    })
                    stepDisplay.setPosition(evt.latLng);
                    stepDisplay.open(map);
                });
                google.maps.event.addListener(stepPolyline, 'mouseout', function(evt) {
                    this.setOptions({
                        strokeWeight: 4
                    });
                    stepDisplay.close(map);
                });
                polylines.push(stepPolyline);
                stepPolyline.setMap(map);
            }
        }
    }
    #map {
      height: 100%;
    }

    html,
    body {
      height: 100%;
      margin: 0;
      padding: 0;
    }
<!DOCTYPE html>
<html>

<head>
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
  <meta charset="utf-8">
  <title>Travel modes in directions</title>
  <link href="http://code.google.com//apis/maps/documentation/javascript/examples/default.css" rel="stylesheet">
</head>

<body>
  <div id="map"></div>
</body>
  <script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk&language=pt&callback=initMap">
  </script>
</html>

Why a few this same components works differently in react?

I have the following component named Card:

<article className={styles.card_container}>
        <input type="checkbox" className={styles.checkbox} onClick={setCheckbox}/>
        <div className={styles.text_container} id="txt_container">
            <span>
                {props.number}
            </span>
        </div>
    </article>

Which should display checkbox, without the tick – container to check or not, with background colors, depends on this checkbox is checked or not.
For example, when unchecked this should has red color, but when checked – black.
For this, I decided to use state:

const [isChecked, setChecked] = useState(false);

const setCheckbox = (e) => {
    if (isChecked===true){
        setChecked(false);
        document.getElementById("txt_container").style.backgroundColor="#a81616";
    }else {
        setChecked(true);
        document.getElementById("txt_container").style.backgroundColor="#000";
    }
}

I wanted to create a few this type of components so I decided to map this with information from array:

{data.map(element=>
                <Card number={element.option} key={element.option}/>)
            }

(Where data is an array with object with numbers, Card is created components with code above).
The problem is that, when I “check” other components, it change color only at first.
Why did it happen? I appreciate for any help.

And there some css code:

    .card_container {
    position: relative;
    width: 60px;
    height: 45px;
    margin: 5px;
    float: left;
    border: 2px solid #50bcf2;
    box-sizing: border-box;
}

.text_container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 25px;
    transition: .5s ease;
}

.checkbox {
    position: absolute;
    top: 0;
    left: 0;
    width: 60px;
    height: 45px;
    opacity: 1;
    cursor: pointer;
}

I would like to do this by js, is there other way to do this (not by css)? Or maybe can I inject background color provided by props from for example an array to Card component?

Nested fetch is undefined is Svelte {#await} block

I am using poke api https://pokeapi.co/ to learn Svelte – I use fetch to get the list of pokemons and nested fetch call to get the image url of every pokemon fetched. While console.logging the result, the array of pokemons is looking fine, with imgUrl appended.

JavaScript (Svelte):

async function fetchGroup() {
    const response = await fetch('https://pokeapi.co/api/v2/type/11').then(result => result.json());
    response.pokemon.forEach(async (elem, index) => {
        const imgUrl = await fetch(elem.pokemon.url).then(result => result.json().then(result => result.sprites.front_default))
        elem.pokemon = { ... response.pokemon[index].pokemon, ... { imgUrl : imgUrl }}
    })
    console.log(response.pokemon); // this log returns the correct obejct with imgUrl appended
    return response.pokemon;
}

However, that appended value seems to be undefined inside {#await} block

{#await pokemonsList}
    waiting...
    {:then response}
        {#each response as responseItem}
            {responseItem.pokemon.name} this is alright!
            {responseItem.pokemon.imgUrl} this is undefined 
        {/each}
    {:catch error}
        {error.message}
{/await}

What’s wrong here?

How to store multiple values separately from the native base picker

enter image description here

I have product attributes like the image above for which I’m mapping the otherDetails array to get the keys i.e. size, color and its variations like small, large etc. To get the variations I’m mapping productValue array. Then I’m showing it in the picker like this

             {product.otherDetails.map((item) => (
                <View style={styles.mainText}>
                  <Text
                    style={{
                      fontSize: RFPercentage(1.6),
                      marginLeft: width / 3,
                      textTransform: "uppercase",
                    }}
                  >
                    {item.productKey}
                  </Text>
                  <View style={{ width: width / 3.2 }}>
                    <Picker
                      note
                      mode="dropdown"
                      selectedValue={attributes}
                      onValueChange={onChangeAttributes.bind(this)}
                    >
                      <Picker.Item label="Select" value="select" />
                      {item.productValue?.map((product) => (
                        <Picker.Item
                          label={product.attributeName}
                          value={product.attributeName.toLowerCase()}
                        />
                      ))}
                     </Picker>

Its rendering fine on the UI but now I want to store the user choice w.r.t the keys. For instance we have two productKeys i.e. size and color, if the user chooses small from the size key and red from the color key. How can I store them separately in a state? and also be able to update the choices w.r.t the keys.

Google Maps Javascript api zoom issue with marker

I’ve a simple map with an svg file as marker icon. When the map is loaded no problem but, if i try to zoom in or out, the marker changes position (visually) and this is a problem.
The marker must not change position but remain fixed on the reference point.
How can I solve this problem ?

<style type="text/css">
    body { font: normal 10pt Helvetica, Arial; }
    #map { width: 100%; height: 100%; border: 0px; padding: 0px; }
</style>
<script src="https://maps.google.com/maps/api/js?libraries=geometry&key=AIzaSyBpL5_1SzkA3Q6LATyd19-8g5F_Zq_6w70" type="text/javascript"></script>
<script type="text/javascript">
    var icon = {
        url: "https://www.aisilbagno.it/wp-content/uploads/2015/04/google-maps-marker-for-residencelamontagne-hi.png", // url
        scaledSize: new google.maps.Size(50, 50), // scaled size
        origin: new google.maps.Point(0,0), // origin
        anchor: new google.maps.Point(0, 0), // anchor
    };
    var icon2 = {
        url: "https://cdn-icons-png.flaticon.com/512/1119/1119071.png", // url
        scaledSize: new google.maps.Size(50, 50), // scaled size
        origin: new google.maps.Point(0,0), // origin
        anchor: new google.maps.Point(0, 0), // anchor
    };
    var center = null;
    var map = null;
    var currentPopup;
    var bounds = new google.maps.LatLngBounds();
    function addMarker(icon, lat, lng, info) {
        var pt = new google.maps.LatLng(lat, lng);
        bounds.extend(pt);
        var marker = new google.maps.Marker({
            position: pt,
            icon: icon,
            map: map
        });
        var popup = new google.maps.InfoWindow({
            content: info,
            maxWidth: 350
        });
        google.maps.event.addListener(marker, "click", function() {
            if (currentPopup != null) {
                currentPopup.close();
                currentPopup = null;
            }
            popup.open(map, marker);
            currentPopup = popup;
        });
        google.maps.event.addListener(popup, "closeclick", function() {
            map.panTo(center);
            currentPopup = null;
        });
    }      

    function initMap() {
        map = new google.maps.Map(document.getElementById("map"), {
            center: new google.maps.LatLng(40.8319300, 16.4521000),
            zoom: 16,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            mapTypeControl: true,
            mapTypeControlOptions: {
                style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR
            },
            navigationControl: false,
            navigationControlOptions: {
                style: google.maps.NavigationControlStyle.ZOOM_PAN
            }
        });
        addMarker(icon, 43.8219355, 16.4221334, '<b>test1</b>');
        addMarker(icon, 43.8312300, 16.4121000, '<b>test2</b>');
        addMarker(icon2, 43.8319300, 16.4521000, '<b>test3</b>');
   }
</script>
    <body onLoad="initMap()" style="margin:0px; border:0px; padding:0px;">
       <div id="map"></div>
    </body>

enter image description here

How to add linear gradient overlay on google maps iframe?

Hey Guys I am trying to add linear gradient on Google Maps iframe ,I successfully added the overlay div on the iframe using position relative and absolute concepts ;but if I do it that way I am not able to access the map.

.map{
    position: relative;
  
}
iframe{
    z-index: 1;
}
.overlay{
    position: absolute;
    width: 100%;
    height: 450px;
    background-image: linear-gradient(to right, rgba(255,0,0,0), rgb(51, 51, 51));
    top:0;
    z-index: 0;
}
<div class="map_section">
                <div class="map">
                    
                    <iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d424143.2713133365!2d150.65178422173113!3d-33.84792702661292!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x6b129838f39a743f%3A0x3017d681632a850!2sSydney%20NSW%2C%20Australia!5e0!3m2!1sen!2sin!4v1641639710179!5m2!1sen!2sin" width="100%" height="450" style="border:0;" allowfullscreen="" loading="lazy" class="map_bg" >
                      
                    </iframe>
                    <div class="overlay"></div>
                </div>

            </div>

Issue with data to be displayed based on filter in reactjs

I am a new in reactjs and getting issue with data to be displayed based on loaded from server and filtered based on some tags.

The issue is data getting returned in the array map. But, not making it displayed to the elements.
I have created the codes in below link.

https://codepen.io/ssubham/pen/abLaodV

The codes are as :-

import React, {useState, useCallback, useEffect} from 'react';
import Axios from "axios";
import { Container, Grid, Stack, Typography, Button } from "@mui/material";
import moment from "moment";

import OwlCarousel from "react-owl-carousel";
import "owl.carousel/dist/assets/owl.carousel.css";
import "owl.carousel/dist/assets/owl.theme.default.css";

import {} from "./CourseContent.css";

const CourseContent = (props) => {
  const [courseData, setCourseData] = useState([]);
  const [programLevel, setProgramLevel] = useState({
    level: "personal",
    learning: "beginner"
  });

  // Filtering data based on level and learning state to view in Carousel.
  const filterCourseData = useCallback((pData, tempCourseData) => {
    console.log("filterCourseData ", tempCourseData.length);
    if (tempCourseData.length > 0) {
      const subCourseData1 = tempCourseData.filter((program) =>
        program.level.find(
          (items) =>
            Object.keys(items)[0] === pData.level &&
            Object.values(items)[0].find((items1) => items1 === pData.learning)
        )
      );
      setCourseData(subCourseData1);
      return subCourseData1;
    }
  }, []);

  // Fetching data from database to view.
  const fetchCourses = useCallback(() => {
    Axios.get(`https://demo.qortechno.com/api/v1/courses`)
      .then((response) => {
        if (response.data.success) {
          //console.log("coursecontent ",response.data.data)
          filterCourseData(programLevel, response.data.data);
        }
      })
      .catch((error) => {
        console.log(error);
      });
  }, [programLevel]);

  useEffect(() => {
    fetchCourses();
  }, [fetchCourses]);

  return (
    <Container>
      <Grid className={"courseMaterial"} sx={{ display: "flex", marginTop: 7 }}>
         <OwlCarousel
            navText={[
              "<i class='fas fa-chevron-left'></i>",
              "<i class='fas fa-chevron-right'></i>"
            ]}
            className="owl-theme owl-carousel" items={1} loop margin={10} nav dotsContainer="false"
 responsiveClass>
            {
              courseData.map((item, index) => {
console.log(item);
                return (
                  <div key={index}>
                    <Typography variant="h5" gutterBottom> {item.name} </Typography>
                    <Stack spacing={1} style={{ marginTop: "1.5em" }}>
                      <Typography variant="h5">{item.deliverymode}</Typography>
                      <Typography variant="h5"> {item.duration} Weeks
                      </Typography>
                    </Stack>
                  </div>
                );
              })
            }
          </OwlCarousel>
      </Grid>
    </Container>
  );
};

export default CourseContent;

Thanks…