JavaScript calculator is concatenating numbers instead of stringing operations [duplicate]

Currently working on a calculator and I’m able to display the operators and numbers along with storing them in a variable. I’m unable to input multiple numbers and operators, for example 1 + 1 concatenates to 11.

Since I thought I might need a second operand variable I’ve tried adding an addition assignment with a second number variable

secondNum += number.value displayCurrent.textContent = secondNum

But it gave me the same behavior.

What I’m expecting is 1 + 1 – 3 basically trying to string operators together instead of concatenating numbers.

const numbers = document.querySelectorAll(".number");
const displayCurrent = document.getElementById("current");
const displayResult = document.getElementById("result");
const operators = document.querySelectorAll(".operator");
const equals = document.getElementById("equal");
document.getElementById("current").style.height = "100px";
document.getElementById("current").style.margin = "0px 10px";

let firstNum = "";
let savedOperator = "";
let secondNum = ""

const add = function (a, b) {
    return a + b;
}

const subtract = function (a, b) {
    return a - b;
}

const multiply = function (a, b) {
    return a * b;
}

const divide = function (a, b) {
    return a / b;
}

const operate = function (a, operator, b) {
    const operators = {
        "+": (a, b) => add(a, b),
        "-": (a, b) => subtract(a, b),
        "*": (a, b) => multiply(a, b),
        "/": (a, b) => divide(a, b),
    }
    return operators[operator](a, b);
}

// console.log(operate(5, "+" , 5))

displayCurrent.textContent = 0;

for (const number of numbers) {
    number.addEventListener("click", () => {
        // Storing first number/numbers that is input
        firstNum += number.value
        displayCurrent.textContent = firstNum;
        
    })
}

for (const operator of operators) {
    operator.addEventListener("click", () => {
        // Storing first operator that is input
        savedOperator = operator.value
        displayCurrent.textContent = firstNum + savedOperator;
        console.log(firstNum + savedOperator)
    })
}
@import url('https://fonts.googleapis.com/css2?family=Quicksand&family=Raleway:wght@200&display=swap');

body {
   display: flex;
   flex-direction: column;
   justify-content: center;
   align-items: center;
   font-family: "Quicksand", sans-serif;
   height: 500px;
}

.buttons {
    display: grid;
    font-family: "Quicksand", sans-serif;
    height: 50px;
    grid-template-columns: repeat(4, 80px);
    grid-template-rows: repeat(5, 80px);
} 

.display-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    background: #c0c0c0a8;
    width: 320px;
    height: 90px;
    margin-top: 10px;
    margin-bottom: 10px;
    border-radius: 3px;
}

.display-result {
    font-size: 45px;
}

.display-current {
    font-size: 25px;
    margin-bottom: 5px;
}

.number, .operator, #clearBtn, #equal, #decimal {
    font-size: 25px;
    font-family: "Quicksand", sans-serif;
    text-align:center;
    text-decoration:none; 
    transition: all 0.2s;
} 

.number:hover, #decimal:hover {
    background-color:rgb(155, 155, 155);
}

#multiplication, #division, #subtraction, #addition {
    background-color: orange;
    border-radius: 3px;
}

#equal {
    background-color: rgb(0, 180, 0);
    grid-row: span 2;
    border-radius: 3px;
}

#equal:hover{
    background-color: rgb(0, 155, 0);
}

#clearBtn, #deleteBtn {
    background-color: rgb(250, 110, 110);
    border-radius: 3px;
}

#clearBtn:hover, #deleteBtn:hover {
    background-color: rgb(177, 0, 0);
}

#multiplication:hover, #division:hover, #subtraction:hover, #addition:hover {
    background-color: rgb(196, 127, 0);
}

#zero {
    grid-column: span 2;
}

#decimal {
    font-weight: 600;
}
<!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">

    <title>Calculator</title>

    <link rel="stylesheet" href="styles.css">
    <script src="script.js" defer></script>
</head>
<body>
    <div class=" display-container">
        <div class="display-current" id="current"></div>
                <div class="display-result" id="result"></div>
        </div>
        <div class="buttons">
        <button class="clear" id="clearBtn">C</button>
        <button class="operator" id="deleteBtn">↵</button>
        <button class="operator" id="division" value=" ÷ ">÷</button>
        <button class="operator" id="multiplication" value=" × ">×</button>
        <button class="number" id="seven" value="7">7</button>
        <button class="number" id="eight" value="8">8</button>
        <button class="number" id="nine" value="9">9</button>
        <button class="operator" id="subtraction" value=" - ">-</button>
        <button class="number" id="four" value="4">4</button>
        <button class="number" id="five" value="5">5</button>
        <button class="number" id="six" value="6">6</button>
        <button class="operator" id="addition" value=" + ">+</button>
        <button class="number" id="one" value="1">1</button>
        <button class="number" id="two" value="2">2</button>
        <button class="number" id="three" value="3">3</button>
        <button class="equals" id="equal">=</button>
        <button class="number" id="zero" value="0">0</button>
        <button class="decimal" id="decimal">.</button>
    </div>
</div>
</body>
</html>

custom palette not working in react js material ui

I am trying to customize the palette colors for my project but I’m able to use only main attribute of it and not other. I am using MUI under JavaScript not Typescript

import './App.css';
import {BrowserRouter as Router, Route, Routes} from 'react-router-dom'
import Navbar from './components/Navbar/Navbar';
import { createTheme, ThemeProvider } from '@mui/material/styles';
import Home from './components/Home/Home';
import Contact from './components/Contact/Contact';
import Pricing from './components/Pricing/Pricing';
import About from './components/About/About';

const theme = createTheme({
  palette: {
    primary: {
      light: '#f5f6fc', //highlight
      main: '#f6f6f6',  //site bg gray...this works (light, dark doesn't)
      dark: '#000629',   //navbar items
      contrastText: '#fff', //main text large font
    },
    
    secondary: {
      light: '#cdd0d9', //paragraph text dark gray
      main: '#dce6ff',  // for content bg light blue......this works (light, dark doesn't)
      dark: '#ba000d',  //hover buttons
      contrastText: '#000',
    },
  },
});


Google Big Query and Google Maps authentication error

I followed the instructions present in the https://www.cloudskillsboost.google for using Google Big Query data with Google Maps API.

Below is the final code

<!DOCTYPE html>
<html>
<!--
Copyright 2016 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
  <head>
    <title>Simple Map</title>
    <meta name="viewport" content="initial-scale=1.0">
    <meta charset="utf-8">
    <style>
      html, body {
        height: 100%;
        margin: 0;
        padding: 0;
      }
      #map {
        height: 100%;
      }
    </style>
    <script>
    // general vars

    let recordLimit = 10000;
    let jobCheckTimer;
    let heatmap;

    let map;
    let drawingManager;
    // ClientID var
    let clientId = '79499078098-v8cvtlsdi1rlkbrq3lfmeqcvmuabvp7b.apps.googleusercontent.com';

    
    

    
    let scopes = 'https://www.googleapis.com/auth/bigquery';
    
    // BigQuery vars

    let gcpProjectId = 'localis-backend';
    let bigQueryProjectId = 'bigquery-public-data';
    let datasetId = 'new_york';
    let tableName = 'tlc_yellow_trips_2016';

    // initMap
    function initMap() {
        map = new google.maps.Map(document.getElementById('map'), {
            center: {lat: 40.744593, lng: -73.990370}, // Manhattan, New York.
        zoom: 15
        });
        // call setupDrawingTools
        setUpDrawingTools();
    }
    // setUpDrawingTools
    function setUpDrawingTools(){
      // Initialize drawing manager.
      drawingManager = new google.maps.drawing.DrawingManager({
        drawingMode: google.maps.drawing.OverlayType.CIRCLE,
        drawingControl: true,
        drawingControlOptions: {
          position: google.maps.ControlPosition.TOP_LEFT,
          drawingModes: [
            google.maps.drawing.OverlayType.CIRCLE,
            google.maps.drawing.OverlayType.RECTANGLE
          ]
        },
        circleOptions: {
          fillOpacity: 0
        },
        rectangleOptions: {
          fillOpacity: 0
        }
      });
      drawingManager.setMap(map);
      // each one of these handlers do nothing currently, we will replace them later
      // with working code
      // rectangle search handler
      drawingManager.addListener('rectanglecomplete', rectangle => rectangleQuery(rectangle.getBounds()));
      // circle search handler
      drawingManager.addListener('circlecomplete', circle => circleQuery(circle));
    }
    // authorize
    function authorize(event) {
      gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: false}, handleAuthResult);
      return false;
    }
    // handleAuthResult
    function handleAuthResult(authResult) {
      if (authResult && !authResult.error) {
        loadApi();
        return;
      }
      console.error('Not authorized.')  
    }

    
    // loadApi
    function loadApi(){
      gapi.client.load('bigquery', 'v2').then(
       () => initMap()
      );
    }
    // sendQuery

    function sendQuery(queryString){
      let request = gapi.client.bigquery.jobs.query({
          'query': queryString,
          'timeoutMs': 30000,
          'datasetId': datasetId,
          'projectId': gcpProjectId,
          'useLegacySql':false
      });
      request.execute(response => checkJobStatus(response.jobReference.jobId));
    }

    // checkJobStatus

    function checkJobStatus(jobId){
      let request = gapi.client.bigquery.jobs.get({
        'projectId': gcpProjectId,
        'jobId': jobId
      });
      request.execute(response => {
        if (response.status.errorResult){
          // Handle any errors.
          console.log(response.status.error);
          return;
        }
        if (response.status.state == 'DONE'){
          // Get the results.
          clearTimeout(jobCheckTimer);
          getQueryResults(jobId);
          return;
        }
        // Not finished, check again in a moment.
        jobCheckTimer = setTimeout(checkJobStatus, 500, [jobId]);       
      });
    }

    // getQueryResults

    function getQueryResults(jobId){
      let request = gapi.client.bigquery.jobs.getQueryResults({
        'projectId': gcpProjectId,
        'jobId': jobId
      });
      request.execute(response => doHeatMap(response.result.rows))
    }
    // doHeatMap
    function doHeatMap(rows){
      let heatmapData = [];
      if (heatmap!=null){
        heatmap.setMap(null);
      }
      for (let i = 0; i < rows.length; i++) {
          let f = rows[i].f;
          let coords = { lat: parseFloat(f[0].v), lng: parseFloat(f[1].v) };
          let latLng = new google.maps.LatLng(coords);
          heatmapData.push(latLng);
      }
      heatmap = new google.maps.visualization.HeatmapLayer({
          data: heatmapData
      });
      heatmap.setMap(map);
    }
    // rectangleQuery
    function rectangleQuery(latLngBounds){
      let queryString = rectangleSQL(latLngBounds.getNorthEast(), latLngBounds.getSouthWest());
      sendQuery(queryString);
    }
    // rectangleSQL
    function rectangleSQL(ne, sw){
      var queryString = 'WITH SHAPE AS (select ST_MAKEPOLYGON(ST_MakeLine(['
      queryString += 'ST_GEOGPOINT(' + ne.lng() + ',' + ne.lat() +'), '
      queryString += 'ST_GEOGPOINT(' + sw.lng() + ',' + ne.lat() +'), '
      queryString += 'ST_GEOGPOINT(' + sw.lng() + ',' + sw.lat() +'), '
      queryString += 'ST_GEOGPOINT(' + ne.lng() + ',' + sw.lat() +')])) '
      queryString += 'AS POLY) '
      queryString += 'SELECT pickup_latitude, pickup_longitude '
      queryString +=  'FROM `' + bigQueryProjectId +'.' + datasetId + '.' + tableName + '`,SHAPE '
      queryString += 'WHERE ST_CONTAINS(POLY, ST_GEOGPOINT(pickup_longitude,pickup_latitude)) is TRUE'
      queryString += ' LIMIT ' + recordLimit;
      return queryString;
    }
    // circleQuery
    function circleQuery(circle){
      let queryString = circleSQL(circle.getCenter(), circle.radius);
      sendQuery(queryString);
    }

    // circleSQL
    function circleSQL(center, radius){
        var queryString;
        var centerLat = center.lat();
        var centerLng = center.lng();
        var kmPerDegree = 111.045;
        queryString = 'SELECT pickup_latitude, pickup_longitude '
        queryString += 'FROM `' + bigQueryProjectId +'.' + datasetId + '.' + tableName + '` ';
        queryString += 'WHERE ST_DISTANCE(ST_GEOGPOINT(pickup_longitude,pickup_latitude),'
        queryString += 'ST_GEOGPOINT('+ centerLng + ', ' + centerLat + ')) <'+ radius;
        queryString +=' AND dropoff_latitude <> 0.0'
        queryString +=' LIMIT ' + recordLimit;
        return queryString;
    }
</script>
  </head>
  <body>
    <div id="map"></div>
    <!-- Javascript Libraries -->
    <script src='https://maps.googleapis.com/maps/api/js?libraries=visualization,drawing&key=AIzaSyAsq2XOSs_fHv4ufqpPA9sarjQYznFfdgdI' async defer></script>
    <!-- BigQuery API -->
    <script src='https://apis.google.com/js/client.js'></script>
    <!-- Authorize Code -->
    <script type='text/javascript'>
        gapi.load('client:auth', authorize);
    </script>
  </body>
</html>

(API-key and Client ID are dummies)

I followed each step diligently and at first, it seems to work. after the first try, I get a “Not Authorized” error on the console(F12) of my browser. I set the Oauth consent to testing mode and the URL is passed into the App credentials. Could not find a way to overpass this issue with multiple tries.

Reference link:-https://www.youtube.com/watch?v=sWvrUgdj8-E

Enclosed the error message below
enter image description here

How to insert an element value – using jQuery – into an alert box

I am trying to add the Strong element to the alert box in this scenario. However it is returning “undefined”.

Can someone let me know where I have gone wrong with my syntax here. Thanks

CSS

        $('.copyURL').click(function(e){
            e.preventDefault();
            let ele = $(this).parent().siblings(':first-child').children();
            let label = $(this).parent().parent().siblings(':first-child').children();
            ele[0].select();
            ele[0].setSelectionRange(0, 99999);
            navigator.clipboard.writeText(ele[0].value);
            alert(label[0].value + "rn" + "rn" +
            "Copied: " + ele[0].value + "rn" + "rn" + "Use this link for your WEB site");
        });

HTML

                    <div>
                        <label>
                            <strong>Copy This Strong Label Into Alert</strong>
                        </label>
                        <div class="row collapse">
                            <div class="columns small-7">
                                <input type="text" value="<#servername>/<#Database_Name>/<#business_business>/gift" readonly>
                            </div>
                            <div class="columns small-2">
                                <a class="button full-width" href="./<#business_business>/gift" target="_blank">View</a>                                
                            </div>
                            <div class="columns small-3">
                                <a class="button full-width secondary copyURL"><i class="far fa-clone"></i> Copy URL</a>
                            </div>
                        </div>
                    </div>

How to apply CSS style to HTML file that is inside the public folder of React JS

I’m learning React JS.I can apply CSS style to components that is inside the src folder.
But here is the query, how can I apply CSS style to a body tag of HTML file which is sitting inside the public folder. I have tried putting the CSS style inside the HTML file but it’s not reflecting

<!DOCTYPE html>
<html lang="en">
  <head>
    <style>
      .body {
    background-color : blue ;
    margin: auto ;
    width: 50% ;
    display: flex ;
    flex-direction: column ;
    align-items: center ;
    border: 1px solid #efefef ;
    box-shadow :
    /* The top layer shadow */
    Ⓒ 1px 1px rgba ( 0,0,0,0.15 ),
    /* The second layer */
    Ⓒ 10px 0 5px #eee ,
    /* The second layer shadow */
    Ⓒ 10px 1px -4px rgba ( 0,0,0,0.15 ) ,
    /* The third layer */
    Ⓒ 20px 0-10px #eee ,
    /* The third layer shadow */
    Ⓒ 20px 1px -9px rgba ( 0,0,0,0.15 ) ;
    padding: 30px;
    
    }
    </style>



    <meta charset="utf-8" />
    <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="theme-color" content="#000000" />
    <meta
      name="description"
      content="Web site created using create-react-app"
    />
    <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
    <!--
      manifest.json provides metadata used when your web app is installed on a
      user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
    -->
    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
    <!--
      Notice the use of %PUBLIC_URL% in the tags above.
      It will be replaced with the URL of the `public` folder during the build.
      Only files inside the `public` folder can be referenced from the HTML.

      Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
      work correctly both with client-side routing and a non-root public URL.
      Learn how to configure a non-root public URL by running `npm run build`.
    -->
    <title>React App</title>
  </head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
    <!--
      This HTML file is a template.
      If you open it directly in the browser, you will see an empty page.

      You can add webfonts, meta tags, or analytics to this file.
      The build step will place the bundled scripts into the <body> tag.

      To begin the development, run `npm start` or `yarn start`.
      To create a production bundle, use `npm run build` or `yarn build`.
    -->
  </body>
</html>

I have CSS file inside the src folder and imported it to index.js

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import 'bootstrap/dist/css/bootstrap.css'
import './style.css'

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<App/>)

Wait for user response before asking next statement – nodejs

I am trying to register on my website via whatsapp
but my code and api is running before even im enterring my email and other requirements.
i want to ask user for email and wait for user input and adter that i will ask password and so on.
after all this the api should run.
anyone know whats the error in my code.

else if (lastMsgId && lastMsgId === 'MainMenu' && text == 1) {
        await chat.sendMessage(`Please provide following details to register as seller:`);
        await chat.sendMessage(`Email Id`);
        user['lastMsgId'] = 'Email Id';
        await chat.sendMessage('Username')
        user['username'] = 'Username';
        await chat.sendMessage('Password')
        user['password'] = 'Password';
        await axios.post('mydomain.com/wp-json/wp/v2/users',{
            email: user['lastMsgId'],
            username: user['username'],
            password: user['password'],
            roles: 'Store Vendor'
        })
        .then(function (response) {
            console.log(response);
        })
        .catch(function (error) {
            console.log(error);
        });

My Darkmode not save in localstorage Svelte

hello devs I’m trying to save my dark mode in localstorage but I can’t I’ve been trying for hours and I don’t see documentation that works for me I’m using svelte not sveltekit
Sorry for my english i’m not a native and sorry for my ask i am new in development and in stackoverflow

// This is my store but not work the localStorage
import {writable} from 'svelte/store';


const storedTheme = localStorage.getItem("darkmode");
export let darkmode=writable(storedTheme);
darkmode.subscribe(value => {
    localStorage.setItem("darkmode", value===false ? false : true);
});

// and in my switch  archieve i got this
<script>
  import {darkmode} from '../store/Store';
    const handleClick=()=>{
        darkmode.update(darkmode=>!darkmode);
    };
</script>

How to use $this.nextTick() to emit event to parent component after child component finishes rendering?

I have two components, parentComponent and childComponent.

parentComponent passes a prop called booleanValue to childComponent whose value is used inside the nextTick() callback to perform some processing.

My child component is performing its method likeso:

mounted() {
this.$nextTick(()=>{
      if (this.booleanValue){
        alert('You got it!')
        this.$emit('event-name');
      }
    })
  }
}

and my parent component processes it like so:

<child-component 
    v-on:event-name=eventMethod
    v-bind:booleanValue=this.booleanValue>
</child-component>

and my eventMethod() is described under methods: {...}

My code is syntactically correct but I can’t get the nextTick to perform it in the way I want to. What I’m trying to achieve is that the child component would finish rendering the new DOM and then emit an event back to the parent who then does some other processing.

What am I doing wrong? I would prefer to use this solution instead of attempting to solve via other implementations like the Options API, if possible. I haven’t learned that yet and I fear I’ll be introducing more frustration if I try to learn it now for this one problem.

Function is not pulling up the entire array value in typescript

The program has to put all the letters together but it is not working. I’ve tried with the debugger but does not show any errors. The code:

var phrase = [ 'h', 'e', 'l', 'l', ' ', 'w', 'o', 'r', 'l', 'd' ];

let sentence: string[] = createSentence(phrase);

sentence.forEach(letter => {
    console.log(letter);
});

function createSentence(letters: string[]): string[]
{
    var add = "";
    var result: string[] = [];

    phrase.forEach(unionL => {
        if (unionL != ' ') {
            add += unionL;
        } else {
            result.push(add);
            add = "";
        }
    });

    return result;
}

Hide elements using drag and drop

i was wandering how i can hide elements in a div, which has the same class name as another div. i do not want to change the class name, because it will effect my JavaScript. So i want one div acting as like a folder, it is kinda like a drag and drop system. I used a tutorial from Web Dev Simplified. Here is the tutorial if anyone is interested. https://www.youtube.com/watch?v=jfYWwQrtzzY&ab_channel=WebDevSimplified

const draggables = document.querySelectorAll('.draggable')
// create const with class draggable what you can drag
const containers = document.querySelectorAll('.container')
 const containerx =document.querySelector('.containerx')
// containers where to drop.

// loop through each pages
draggables.forEach(draggable => {
    //DRAGSTRT EVENT
    draggable.addEventListener('dragstart',()=> {
        draggable.classList.add('dragging')
    })//what happends when we start draghging element

    // DRAGEND EVENT
    draggable.addEventListener('dragend', () => {
        draggable.classList.remove('dragging')
    })
})

// Allow elements to be dropped in containers
containers.forEach(container=>{
    container.addEventListener('dragover', e =>{
        e.preventDefault() // enable dropping remove default
        const draggable = document.querySelector('.dragging')
        //1 element willl have 'dragging' bc one selected
        container.appendChild(draggable)
       
      //SORT 
        const afterElement = getDragAfterElement(container, e.clientY)
        if(afterElement ==null){
            container.appendChild(draggable)
        }else{
            container.insertBefore(draggable,afterElement)
        }
      
    })
})


//sorting mouse position 
function getDragAfterElement(container, y)
{   //every draggable that we are not dragging
    const draggableelements =  [...container.querySelectorAll('.draggable:not(.dragging)')]
 
  
    return draggableelements.reduce((closest,child)=> {
    const box = child.getBoundingClientRect()
    const offset =(( y - box.top) - box.height) / 2 //mouse position between center boxes
    
    if (offset < 0 && offset > closest.offset)
    {
        return{offset: offset,element: child}
    }else{
          return  closest
        }
      },{offset: Number.NEGATIVE_INFINITY}).element
}
body{
    margin:0;
    background-color: rgb(29, 29, 29);
    ;
}
/* NAV */
/* NAV STRT */
nav {
    list-style-type: none;
    font-family:sans-serif;
    margin: 0;
    padding: 0;
    width: 240px;
    background-color: #3a3a3a;
    height: 100%; /*full height */
    position:absolute; /* Make it stick, even on scroll */
    overflow: auto; /* enable scrolling if the sidenav has too much content */
    left: 0;
    font-size: 16px;
}
li a {
    display: block;     /* links as block elements, whole link area click */
    color:white;
    padding: 8px 1px; /*padding between pages*/
    padding-top:20px;
    text-decoration: none;
    text-align: center;
    background-color: #3a3a3a;
  }
  li h1,h3{
      background-color: #3a3a3a;
  }
  
  ul{
      list-style-type: none;
      background-color: #3a3a3a;
  }
    /* change link color on hover */
    li a:hover {
        background-color:#555;
        color: #F3ECEC;
      }
      li:hover {
    background-color: aqua;
      }
     .title { 
        text-align: center;
        color:white;
       
    }
    .title1
    {
        text-align: center;
        color:white;
        background-color: #3C3939;
        padding-top: 20px;
    }
    .divider{
        border-top: 3px solid #bbb;
    }
/* NAV END */
/* Nav end */
/* FOLDER CONTAINER */
.container {
    background-color: #333;
    padding: 1rem;
    margin-top: 1rem;

    position: relative;
    left:0;
    min-height: 274px;
    max-height: 800px;
    min-width:1000px;
    display: grid;
    grid-template-columns: auto auto auto auto;
    overflow-y: scroll;
    overflow-x: hidden;
}
.draggable{
    background-color:rgba(255, 245, 245, 0.945);
    padding: 1rem;
    margin-top: 1rem;
    border:solid black;
    cursor: move; /* change cursor */
    width:128px;
    height: 174px;
    display: grid;
}

.draggable.dragging{
opacity: 0.5;
}
.containerx{
    background-color: #3a3a3a;
    position: absolute;
    left:35%;
    top: 30%;
    height:600px;
}
.containery{
    background-color: #3a3a3a;
    width: 1032px;
    position: relative;
    left:35%;
    height:400px;
    
}

/* END FOLDERS */
/* SCROLLBAR  */
/* width */
::-webkit-scrollbar {
    width: 20px;
  }
  
  /* Track */
  ::-webkit-scrollbar-track {
    background: #f1f1f1;
  }
  
  /* Handle */
  ::-webkit-scrollbar-thumb {
    background: #888;
  }
  
  /* Handle on hover */
  ::-webkit-scrollbar-thumb:hover {
    background: #555;
  }
  /* SCrollbar end */
<!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">
    <title>Document</title>
    <link rel="stylesheet" href="test.css">
    <script src="test.js" defer></script>
</head>
<body>
    <nav>    
        <ul>
            <li><div class="title"><h1>Organize</h1></div></li>
            <li><a href="folders.html">Folders</a></li>
            <li><a href="#">Timeline</a></li>
            <li><a href="pages.html">Pages</a></li>
            <li><a href="home.html">Meetings</a></li>
            <li><div class="title1"><h3>documents</h3></div></li>
            <li></li>
        </ul>
    </nav>
        <div class="containery">
            <div class="container" id="hidden" name="test">
            </div>
        </div>
        

        <div class="containerx">
            <div class="container">
                <p class="draggable" draggable="true">3</p>
                <p class="draggable" draggable="true">4</p>
                <p class="draggable" draggable="true">1</p>
                <p class="draggable" draggable="true">2</p>
                <p class="draggable" draggable="true">3</p>
                <p class="draggable" draggable="true">4</p>
                <p class="draggable" draggable="true">1</p>
                <p class="draggable" draggable="true">2</p>
            </div>
        </div>
   
</body>
</html>

How to get current location without clicking the button in ReactJS?

//*some code
 const [lat, setLat] = useState(null);
 const [lng, setLng] = useState(null);
 const [status, setStatus] = useState(null);

 const getLocation = () => {
      if (!navigator.geolocation) {
           setStatus('Geolocation is not supported by your browser');
      } else {
           setStatus('Locating...');
           navigator.geolocation.getCurrentPosition((position) => {
                setStatus(null);
                setLat(position.coords.latitude);
                setLng(position.coords.longitude);
           }, () => {
                setStatus('Unable to retrieve your location');
           });
      }
 }
 const point = {
      lat: lat,
      lng: lng
 };
 const dest = {
      lat: 123,
      lng: 456
 };
//*some code

I got the reference from here https://javascript.plainenglish.io/how-to-use-the-geolocation-api-in-your-react-app-54e87c9c6c94

javascript how can i run 2 file reader methods(readAsArrayBuffer() & readAsDataURL())?

i currently have the ff code my goal is to remove the extra filreader loop? is it possible to maybe chain the readAsArrayBuffer and readAsDataURL or load them both?

var images = [];
var files = dt.files.length;
for (i = 0; i < files; i++) {
var reader = new FileReader();
reader.fileId = i;
reader.onload = function (){
    images[this.fileId].is_valid = true / false; // checks mime type
}
reader.readAsArrayBuffer(dt.files[i]);

for (i = 0; i < files; i++) {
var reader = new FileReader();
reader.fileId = i;
reader.onload = function (){
    //load image
    if(image[i].is_valid){ 
    // do this
   }else {
    // do this
   }
}

reader.readAsDataURL(dt.files[i]);

Submit form with JS after captcha validation

I’ve just included the sections I thought were relevant. I would like the form to submit once the JS validates Captcha. But it never goes to the next page. What am I missing?

<body>
<div class="wrapper">
    <header>Captcha in JavaScript</header>
    <div class="captcha-area">
      <div class="captcha-img">
        <img src="captcha-bg.png" alt="Captch Background">
        <span class="captcha"></span>
      </div>
      <button class="reload-btn"><i class="fas fa-redo-alt"></i></button>
    </div>
    <form name:"myform" action="checkout5.php" class="input-area" method="post">
      <input type="text" placeholder="Enter captcha" maxlength="6" spellcheck="false" required>
      <button type:"submit" value="submit" class="check-btn">Submit</button>
    </form>
    <div class="status-text"></div>
  </div>
  <script src="script.js"></script>
</body>
<script>
checkBtn.addEventListener("click", e =>{
  e.preventDefault(); //preventing button from it's default behaviour
  statusTxt.style.display = "block";
 let inputVal = inputField.value.split('').join(' ');
  if(inputVal == captcha.innerText){ //if captcha matched
        statusTxt.style.color = "#4db2ec";
        statusTxt.innerText = "Nice! You don't appear to be a robot.";
        setTimeout(()=>{ //calling removeContent & getCaptcha after 2 seconds
        removeContent();
        getCaptcha();
        }, 2000);
  }else{
    statusTxt.style.color = "#ff0000";
    statusTxt.innerText = "Captcha not matched. Please try again!";
  }
});

</script>
</html>