-React timer clock project- Why does the timer dont run? [duplicate]

I am a beginner at programming and I am trying to make a clock project.

I am just at the start of it but my code is already not working. At this point of the project what I am trying to do is just to have the timer running when I click on play.

It would be so nice if I could get a bit of help there.

Here is my code :


import React, { useState } from 'react';
import ReactDOM from 'react-dom'


function App(props) {
 
let minutes = 25
let seconds = 0 

function clockmecanics () {

  if (seconds===0) {

   seconds = 60 
   minutes --
   

 }

 seconds -- 

}

function updater () { 

  while (minutes>0){

 setTimeout(clockmecanics(),1000)

}
}


 
   return (
     <div>
     <h1> CLOCK </h1>
     <h1> Breaklength : 5 </h1>
     <button> +  </button>
     <button> -  </button>

     <h1> Sessionlength : 25 </h1>
     <button> +  </button>
     <button> -  </button>
     
     <h1> {minutes}:{seconds} </h1>

     <button onClick={()=> updater ()}>PLAY</button>
     
     

     <h2>  </h2>

     

       </div>
   )
 }


ReactDOM.render(
 <App />,
 document.getElementById('container')
);

Javascript Clicker Game İsn’t working / The click button is not working

Im trying to make a basic clicker game on JS. But theres a problem.

I tried to make a 2x clicker thing which is the game will ask you if you wanna buy 2x clicker when you reached to 100 clicks. 2x clicks will basically give you 2x clicks.

However i think it broked the entire code since click button is not giving any clicks.

Heres the codes:

JS:

let clickCount = 0;
let clickBoost = false;

document.getElementById("clickButton").onclick = function(){
    clickCount +=1;
    document.getElementById("clickCounter").innerHTML = clickCount;

    if (clickCount += 100){
        let boostyorn = prompt("You have more clicks than 100." + "n" + "n" + "Do you wanna buy 2x Clicks?" + "n" + "(Y/N)")
        if (boostyorn == "Y"){
            document.getElementById("clickCounter").innerHTML = clickCount - 100;
            clickBoost = true;
        }
        else{
            alert("You didn't bought 2x Clicks.")
        }
    }

    if (clickBoost == true) {
        document.getElementById("clickButton").onclick = function () {
            clickCount += 2;
            document.getElementById("clickCounter").innerHTML = clickCount;
    }
}

}

HTML:

<!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>Clicker</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <label id= "clickCounter">0</label><br>
    <center><button id= "clickButton">Click</button></center>
    <label id= "clickBoost"

    <script src="index.js"></script>
</body>
</html>

CSS:

#clickCounter{
    display: block;
    text-align: center;
    font-size: 150px;
}
#clickButton{
    display: block;
    text-align: center;
    font-size: 100px;
}

jquery.min.js:2 jQuery.Deferred exception: Unexpected token < in JSON at position 0 SyntaxError: Unexpected token < in JSON at position 0

window.$(window.document).ready(function ($) {
    "use strict";

    //Notification options
    window.toastr.options = {
      "closeButton": false,
      "debug": false,
      "newestOnTop": false,
      "progressBar": false,
      "positionClass": "toast-top-center",
      "preventDuplicates": true,
      "onclick": null,
      "showDuration": "300",
      "hideDuration": "1000",
      "timeOut": "5000",
      "extendedTimeOut": "1000",
      "showEasing": "swing",
      "hideEasing": "linear",
      "showMethod": "fadeIn",
      "hideMethod": "fadeOut"
    };

    var username, password; 

    // Login button click event
    $("#login-btn").on("click", function (e) {
        e.preventDefault();

        // Remove alert box, if exist
        $(window.document).find(".alert").remove();

        var $tag = $(this);
        var $usernameInput = $("input[name="username"]");
        var $passwordInput = $("input[name="password"]");

        // Disable Button & Input fields
        var $btn = $tag.button("loading");
        $usernameInput.attr("disabled", "disabled");
        $passwordInput.attr("disabled", "disabled");

        if (!window.isDemo || (!username || password)) {
          username = $usernameInput.val();
          password = $passwordInput.val();
        }

        // Ajax request to verify access
        $.ajax({
            url: "index.php?action_type=LOGIN",
            type: "POST",
            dataType: "json",
            data: {username: username, password: password},
            success: function (response) {
              if (response.count_user_store > 1) {
                window.location = "store_select.php?redirect_to=" + (getParameterByName('redirect_to') && getParameterByName('redirect_to') !== "undefined" && getParameterByName('redirect_to') !== "null" ? getParameterByName('redirect_to') : '');
              } else {
                $.ajax({
                  url: window.baseUrl + "/"+window.adminDir+"/dashboard.php?active_store_id=" + response.store_id,
                  method: "GET",
                  dataType: "json"
                }).
                then(function(response) {
                  var alertMsg = response.msg;
                  window.toastr.success(alertMsg, "Success!");
                  window.location = getParameterByName('redirect_to') && getParameterByName('redirect_to') !== "undefined" && getParameterByName('redirect_to') !== "null" ? getParameterByName('redirect_to') : window.baseUrl + "/"+window.adminDir+"/dashboard.php";
                }, function(response) {
                  var errorMsg = JSON.parse(response.responseText);
                  var alertMsg = "<div>";
                      alertMsg += "<p>" + errorMsg.errorMsg + ".</p>";
                      alertMsg += "</div>";
                  window.toastr.warning(alertMsg, "Warning!");
                });
              }
            },
            error: function (response) {
                $btn.button("reset");
                $usernameInput.attr("disabled", false);
                $passwordInput.attr("disabled", false);
                if (isHTML(response.responseText)) {
                  window.location = window.baseUrl+"/"+adminDir+"/dashboard.php";
                } else {
                  window.toastr.warning(JSON.parse(response.responseText).errorMsg, "Warning!");
                }
            }
        });
    });

    $("#credentials table tbody tr").on("click", function (e) {
      e.preventDefault();
      username = $(this).find(".username").data("username"); 
      password = $(this).find(".password").data("password");
      $("input[name="username"]").val(username); 
      $("input[name="password"]").val(password); 
      $("#login-btn").trigger("click");
    });

    $(document).delegate(".activate-store", "click", function(e) {
        e.preventDefault();

        var $tag = $(this);
        var actionUrl = $tag.attr("href");
        
        $.ajax({
            url: actionUrl,
            method: "GET",
            cache: false,
            processData: false,
            contentType: false,
            dataType: "json"
        }).
        then(function(response) {
            $(":input[type="button"]").prop("disabled", false);
            var alertMsg = response.msg;
            window.toastr.success(alertMsg, "Success!");
            window.location = getParameterByName('redirect_to') && getParameterByName('redirect_to') !== "undefined" && getParameterByName('redirect_to') !== "null" ? getParameterByName('redirect_to') : window.baseUrl + "/"+window.adminDir+"/dashboard.php";
        }, function(response) {

          var errorMsg = JSON.parse(response.responseText);
          $(":input[type="button"]").prop("disabled", false);
          var alertMsg = "<div>";
              alertMsg += "<p>" + errorMsg.errorMsg + ".</p>";
              alertMsg += "</div>";
          window.toastr.warning(alertMsg, "Warning!");

        });
    });

    // Send Resent Button
    $("#reset-btn").on("click", function (e) {
        e.preventDefault();

        // Remove alert box, if exist
        $(document).find(".alert").remove();

        // Declare button and input fields
        var $tag = $(this);
        var $emailInput = $("input[name="email"]");

        // Disable Button & Input fields
        var $btn = $tag.button("loading");
        $emailInput.attr("disabled", "disabled");
        $("body").addClass("overlay-loader");

        // Ajax request to verify access
        $.ajax({
            url: "index.php?action_type=SEND_PASSWORD_RESET_CODE",
            type: "POST",
            dataType: "json",
            data: {email: $emailInput.val()},
            success: function (response) {
                $("body").removeClass("overlay-loader");
                $btn.button("reset");
                $("input[name="email"]").attr("disabled", false);
                // show success message
                var successMsg = "<div class="alert alert-success">";
                successMsg += "<p><i class="fa fa-check"></i> " + response.msg + ".</p>";
                successMsg += "</div>";
                $(window.document).find(".modal-body").before(successMsg);
            },
            error: function (response) {
                $("body").removeClass("overlay-loader");
                // enable Button & Input fields
                $btn.button("reset");
                $("input[name="email"]").attr("disabled", false);
                // show error message
                var alertMsg = "<div class="alert alert-danger">";
                alertMsg += "<p><i class="fa fa-warning"></i> " + JSON.parse(response.responseText).errorMsg + ".</p>";
                alertMsg += "</div>";
                $(window.document).find(".modal-body").before(alertMsg);
            }
        });
    });

    // Reset Confirm Button
    $("#reset-confirm-btn").on("click", function (e) {
        e.preventDefault();

        // Remove alert box, if exist
        $(document).find(".alert").remove();

        // Declare button and input fields
        var $tag = $(this);

        var $resetCodeInput = $("input[name="fp_code"]");
        var $passwordInput = $("input[name="password"]");
        var $passwordConfirmInput = $("input[name="password_confirm"]");

        // Disable Button & Input fields
        var $btn = $tag.button("loading");
        $passwordInput.attr("disabled", "disabled");
        $passwordConfirmInput.attr("disabled", "disabled");
        $("body").addClass("overlay-loader");

        // Ajax request to verify access
        $.ajax({
            url: "password_reset.php?action_type=RESET",
            type: "POST",
            dataType: "json",
            data: {fp_code: $resetCodeInput.val(),password: $passwordInput.val(),password_confirm: $passwordConfirmInput.val()},
            success: function (response) {
                $("body").removeClass("overlay-loader");
                $btn.button("reset");
                $passwordInput.attr("disabled", false);
                $passwordConfirmInput.attr("disabled", false);
                window.toastr.success(response.msg, "Success!");
                window.location.href = 'index.php';
            },
            error: function (response) {

                $("body").removeClass("overlay-loader");
                // Enable Button & Input fields
                $btn.button("reset");
                $passwordInput.attr("disabled", false);
                $passwordConfirmInput.attr("disabled", false);
                window.toastr.warning(JSON.parse(response.responseText).errorMsg, "Warning!");
            }
        });
    });

    // Centering Loginbox horizontally
    var BoxCentering = function () {
        var $loginBox = $(".login-box");
        var $windowHeight = $(window).height();
        var $loginBoxHeight = $loginBox.innerHeight();
        var $marginTop = ($windowHeight / 2) - ($loginBoxHeight / 2);
        $loginBox.css("marginTop", $marginTop + "px");
    };

    // Login box keeps at center always
    BoxCentering();

    // Centering Login box during scroll
    $(window).on("resize", function () {
        BoxCentering();
    });
});

DOCUMENTOS GCP NÃO FAZ UPLOAD [closed]

Or Google asked for documents to activate minha conta. I sent, but it was wrong. At the time of forwarding or upload button does not work. I don’t know how to contact you to resolve this issue. Does anyone know?

O Google pediu documentos para ativar minha conta. Enviei, mas um estava com erro. Na hora de reenviar o botão upload não funciona. E não sei como fazer contato para resolver isso. Alguém sabe?

enter image description here

postman does not store value

So I am trying to enter a post using postman into a mongo db server but my post just returns empty. When I look into my server nothing has been entered and there is no error

table:

const mongoose = require('mongoose');

//Schema describes how our data looks
const PostSchema = mongoose.Schema({
    fullName: {
        type: String,
        required: true,
    },
    date_created: {
        type: Date,
        default: Date.now
    },
    id: {
        type: Number,
        required: true
    }
});

module.exports = mongoose.model('customer', PostSchema);

Route file

const express = require('express');
const router = express.Router();
const customer = require('../models/customer')
router.post('/', async (req,res) => {
const post = new customer({
    fullName: req.body.fullName,
    id: req.body.id
});
try{
    const savedCust = await customer.save();
    res.json(savedCust);
} catch (err) {
    res.json({message: err});
}
});

module.exports = router;

This is what I submit on postman:

{
    "fullName" : "Joy Robinson",
    "id": 2397
}

And this is the response that I get back:

{
    "message": {}
}

Trying to retrieve an avatar image from an API but receiving an error of avatar not defined

userData is a function that receives user data from an API using getUserByChainAccount. getUserByChainAccount requires a username, which in this case is dynamically retrieved from buyer.

I’m interested in avatar , but I keep getting the following error Unhandled Runtime Error
ReferenceError: avatar is not defined

  return (
    <PageLayout>
      <ul>
        {sales.map((result) => {
          const {
            sale_id,
            buyer,
            seller,
            listing_price,
            listing_symbol,
            created_at_time,
          } = result;
          const userData = async (buyer) => {
            const user = await proton.getUserByChainAccount(buyer);
            const { name, avatar } = user;
          };

          function HandleBuyerClick() {
            window.location = '/user/' + buyer;
          }
          function HandleSellerClick() {
            window.location = '/user/' + seller;
          }

          if (buyer !== null) {
            return (
              <Card>
                <li key={sale_id}>
                  <h3>
                    <Transaction>
                      {avatar}
                      <Button onClick={HandleSellerClick}>{seller}</Button>
                    </Transaction>{' '}
                    just sold item number
                    <Transaction>
                      <Button>{sale_id}</Button>
                    </Transaction>{' '}
                    to{' '}
                    <Transaction>
                      <Button onClick={HandleBuyerClick}>{buyer}</Button>
                    </Transaction>{' '}
                    for <Transaction>{formatNumber(listing_price)}</Transaction>{' '}
                    {listing_symbol} at {parseTimestampJM(created_at_time)}
                  </h3>
                </li>
              </Card>
            );
          }
        })}
      </ul>
    </PageLayout>
  );
}

How is this made? It’s Javascript or some Elementor Plugin?

Hell guys. I have a task with my university class. My task is to do a wordpress site with “my own” customizations.

I already finished the task, on the good way i hope. But i’m trying to make something that my other teammates can’t do, the customization tasks. Recentry i saw a website: cryptonoticias . com and then go some random post, now open the dev console, they have a div which is kinda interesting. if you go on this website and seach on dev console the div: “class=”cri_shortcode” you will see something like a affiliate site. I have experience with elementor and wordpress ( 4/10 score skill to be honest )m but i don’t know how is this made. I want to put on my project website something like this but with recipes, my university project is about cooking website. So in this div they are 4 colums and if you let the mouse hover it show a small popup. Does anybody know how is this possible? it’s not look like a plugin is some js scrip maybe?

Thanks for help guys 🙂

Rock Paper Scissors Javascript not working

I’m learning JS and I’m trying to code a RPS kind of game with a UI, but I’m doing something wrong somewhere and I cannot figure out where.

Whenever I click on one of the options on the UI, the whole thing just freezes. I struggled a bit with the addEventListener logic, but I don’t know if that’s what’s causing it or if it’s something else.

Here’s my HTML and JS.

<!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">
        <link rel="stylesheet" type="text/css" href="css/styles.css">
        <script src="https://kit.fontawesome.com/77133b1b16.js" crossorigin="anonymous"></script>
        <title>Rock, Paper, Scissors, Lizard, Spock</title>
    </head>
    <body>
        <div class="container">
            <div class="title">
                <h1>CHOOSE YOUR WEAPON</h1>
            </div>
            <div class="weapons">
                <div class="button" id="rock">
                    <div><img src="rock.png" alt="rock"></div>
                    <p>Rock</p>
                </div>
                <div class="button" id="paper">
                    <div><img src="paper.png" alt="paper"></div>
                    <p>Paper</p>
                </div>
                <div class="button" id="scissors">
                    <div><img id="scissors" src="scissors.png" alt="scissors"></div>
                    <p>Scissors</p>
                </div>
                <div class="button" id="lizard">
                    <div><img src="lizard.png" alt="lizard"></div>
                    <p>Lizard</p>
                </div>
                <div class="button" id="spock">
                    <div><img src="spock.png" alt="spock"></div>
                    <p>Spock</p>
                </div>
            </div>
            <h1 class="score-title">Score</h1>
            <div class="score">
                <div class="playerScore">
                    <h2>You</h2>
                    <span id="playerScore"></span>
                </div>
                <div class="computerScore">
                    <h2>Me</h2>
                    <span id="computerScore"></span>
                </div>
            </div>
            <span id="message"></span>
            <div class="rules">
                <h3>Rules:</h3>
                <p>"Scissors cuts Paper, Paper covers Rock, Rock crushes Lizard, Lizard poisons Spock, Spock smashes Scissors, Scissors decapitates Lizard, Lizard eats Paper, Paper disproves Spock, Spock vaporizes Rock, and as it always has, Rock crushes Scissors."</p>
            </div>
        </div>
        <footer class="footer">
            <p>Copyright © CamiCoding 2022</p>
            <a href="https://www.github.com/CamiCoding/" target=”_blank”><i class="fa-brands fa-github fa-beat" style="--fa-beat-scale: 2.0;"></i></a>
        </footer>
        <script src="script.js"></script>
    </body>
    </html>
let weapons = ["rock", "paper", "scissors", "lizard", "spock"];
let playerScore = 0;
let computerScore = 0;
let rounds = 0;
let roundWinner;

const playerScoreNumber = document.getElementById('playerScore');
const computerScoreNumber = document.getElementById('computerScore');
const scoreMessage = document.getElementById('message');
const buttons = document.querySelectorAll('.button');

buttons.forEach(button =>{
    button.addEventListener('click', playRound)
})

function playRound(event) {
    playerSelection = event.target.id;
    let computerSelection = computerPlay();

    if (playerSelection == computerSelection) {
        roundWinner = 'tie';
    } else if (
        (playerSelection == "paper" && computerSelection == "scissors") ||
        (playerSelection == "rock" && computerSelection == "paper") ||
        (playerSelection == "spock" && computerSelection == "lizard") ||
        (playerSelection == "lizard" && computerSelection == "rock") ||
        (playerSelection == "spock" && computerSelection == "lizard") ||
        (playerSelection == "scissors" && computerSelection == "spock") ||
        (playerSelection == "lizard" && computerSelection == "scissors") ||
        (playerSelection == "paper" && computerSelection == "lizard") ||
        (playerSelection == "spock" && computerSelection == "paper") || 
        (playerSelection == "rock" && computerSelection == "spock") ||
        (playerSelection == "scissors" && computerSelection == "rock")) {

        roundWinner = 'computer';
        computerScore++;
        rounds++;
    } else {
        roundWinner = 'player';
        playerScore++;
        rounds++;
    }
    updateScore();
}

function checkVictory() {
    while(rounds < 5) {
        if (playerScore == 3 || computerScore == 3) {
            break;
        }
        
    }

    if (playerScore > computerScore) {
        scoreMessage.textContent = "Fine, you win this time."
    } else {
        scoreMessage.textContent = "Awww, looks like you lost."
    }
}

function computerPlay() {
    const random = Math.floor(Math.random()*weapons.length);
    return weapons[random];
}

function updateScore() {
    if (roundWinner === 'tie') {
        scoreMessage.textContent = "It's a tie!";
    } else if (roundWinner === 'computer') {
        scoreMessage.textContent = "You lose!";
    } else if (roundWinner === 'player') {
        scoreMessage.textContent = "You win!";
    }

    playerScoreNumber.textContent = `${playerScore}`;
    computerScoreNumber.textContent = `${computerScore}`;
    checkVictory();
}

Thanks a lot in advance!

With GoogleMaps API how to create a vertical pole bearing clickable markers for each dwelling at a shared address, geolocation

I am trying to build an interactive GoogleMap in JavaScript via the API for a small town in which some reside in shared buildings. For such locations I would like to show a vertical “pole” on which there is a clickable marker of my choice for each dwelling and the height of the pole varying depending on the number of dwellings.

Or some other useful visualization for such locations.

Would appreciate suggestions and coding tips.

input onChange is wiping all elements from DOM in React. The input form works well with a button, but can’t seem to work onChange on the first load

So I’m creating a grid that you can resize using two input fields on the app. I have the input for cells across, input for cells down and the button to set the grid which works nicely. I want to change so that the input updates the state stored on cellsAcross and cellsDown. When I remove the button and add the onChange attribute to the input elements, it works if I don’t refresh the browser, but as soon as everything renders for the first time, when adding an input everything in the DOM disappears.

Here’s the code with the button:

function App() {
  const [cellsAcross, setCellsAcross] = useState(5);
  const [cellsDown, setCellsDown] = useState(5);

  const getGridSize = () => {
    const inputAcross = document.getElementById("cells-across").value;
    const cellsAcross = parseInt(inputAcross);
    setCellsAcross(cellsAcross);
    const inputDown = document.getElementById("cells-down").value;
    const cellsDown = parseInt(inputDown);
    setCellsDown(cellsDown);
    console.log(`Across: ${cellsAcross} | Down: ${cellsDown}`);
  };

  

  return (
    <div className="app">
      <Header />
      <CellGrid numberOfColumns={cellsAcross} numberOfRows={cellsDown} />
      <label htmlFor="cells-across">Across</label>
      <input 
        type="number" 
        id="cells-across" 
        name="cells-across" 
        min="1"
      />
      <br />
      <label htmlFor="boxes-down">Down (1-20):</label>
      <input 
        type="number" 
        id="cells-down" 
        name="cells-down" 
        min="1"
      />
      <br />
      <button onClick={getGridSize}>Make Grid</button>
      <br />
    </div>
  );
}

export default App;

And this is what I want it to be:

import React, { useState } from "react";
import CellGrid from "./CellGrid";
import "./App.css";
import Header from "./Header";

function App() {
  const [cellsAcross, setCellsAcross] = useState(5);
  const [cellsDown, setCellsDown] = useState(5);

  const getGridSize = () => {
    const inputAcross = document.getElementById("cells-across").value;
    const cellsAcross = parseInt(inputAcross);
    setCellsAcross(cellsAcross);
    const inputDown = document.getElementById("cells-down").value;
    const cellsDown = parseInt(inputDown);
    setCellsDown(cellsDown);
    console.log(`Across: ${cellsAcross} | Down: ${cellsDown}`);
  };

  return (
    <div className="app">
      <Header />
      <CellGrid numberOfColumns={cellsAcross} numberOfRows={cellsDown} />
      <label htmlFor="cells-across">Across</label>
      <input
        type="number"
        id="cells-across"
        name="cells-across"
        min="1"
        onChange={getGridSize}
      />
      <br />
      <label htmlFor="boxes-down">Down (1-20):</label>
      <input
        type="number"
        id="cells-down"
        name="cells-down"
        min="1"
        onChange={getGridSize}
      />
      
    </div>
  );
}

export default App;

Multiple Inputs with Vite

I’m having multiple inputs when building my app with vite. My config looks like this:

export default defineConfig({
  plugins: [
    react(),
    eslintPlugin()
  ],
  build: {
    rollupOptions: {
      input: {
        test1: resolve(__dirname, '/test1.html'),
        test2: resolve(__dirname, '/test2.html')
      }
    }
  }
});

The output looks like this:

dist
|-test1.html
|-test2.html
|-assets

What I actually want is something like this:

dist
|test1
  |-index.html
|test2
  |-index.html
|-assets

Is this possible?

Thanks

Collect values from a spreadsheet, look for those values in a string and replace

The values in my spreadsheet are these:
enter image description here

/2021/
/20212022/
/2022/
/20222023/
/2023/

To try to find these values in a string and then replace with /@@@@/ I tried creating a map:

var sheet = SpreadsheetApp.getActive().getSheetByName('One')
var liga = 'https://int.testestest.com/national/united-states/mls/2022/regular-season/r66725/'
var years = sheet.getRange('One!A10:A14').getValues().flat();
var mapObj = {one: years[0],two: years[1],three: years[2],four: years[3],five: years[4]};

var liga_substitute = liga.replace(/b(?:one|two|three|four|five)b/gi, matched => mapObj[matched]);

var liga_final_subs = liga_substitute.replace('one','/@@@@/').replace('two','/@@@@/').replace('three','/@@@@/').replace('four','/@@@@/').replace('five','/@@@@/')

But the result after substitution remains the same:

https://int.testestest.com/national/united-states/mls/2022/regular-season/r66725/

My final expected result is:

https://int.testestest.com/national/united-states/mls/@@@@/regular-season/r66725/

And in var liga_final_subs = exist the risk of finding these parts of text in the wrong places and replacing what shouldn’t.

How should I go about doing this correctly?

Should I remove “await” keyword to increase response time?

I’ve database of users where they have created their team. and other document for storing racers.

each user can create a team of 6 racers.

but the problem is that I’ve 50k users and using the below code to remove a racer from their team if Admin deleted it from Racers Document.

I’m using express.js and mongoose

team is an array of object which has racers name, it’s shortCode and unique identifier.

async function delete(req, body){
    // code to validate users input
    await Users.updateMany({'tema.shortCode': 'HAM'}, { $pull: {'team.shortCode': 'HAM'}})

}

I’ve seen that response time decreases if i remove await keyword. But is it recommended to do that.

Bulk download of images using JavaScript

I need a piece of JavaScript code that gets an array of image links and downloads them one by one. I know there are tools for this, but due to some access limitations it needs to be JavaScript code that runs on a page in my browser. I get to write the whole page myself, and browse it as a local file on my computer.

As my input I will have a JavaScript array:

var links = ['https://.../img1.jpg','https://.../img2.jpg','https://.../img3.jpg',...]

I will be using a fairly recent build of Firefox. I have figured out that I can get rid of the Save As dialog if I set the browser to always save to a certain location, and I can get rid of the confirmation dialog by checking “Do this for all files of this type”. I can do the foreach myself, I just need the function I can feed the links to.

You’d think there would be many examples how to do this, and there are, but so far I haven’t found a single one that actually works for me. Either they assume you have a static image on your page and want to initiate download by clicking on it, or they run smack into CORS policy error. I even found one complete example that seemed to be working, but once I downloaded and tried it on my machine, it started producing 4.0 KB garbled downloaded files.

How can I do this?