UseState() throwing a white screen React

im making a react code, it is supposed to grab each value from cardInfo and put it in cards and be able to search and filter each card, this works fine and the filter as well. Although when i add the input with the const [searchTerm, setSearchTerm] = useState(”); I end up with a white screen.

import React from "react";
import { useState } from "react/cjs/react.production.min";
import '../css/productFilters.css';

function ProductsFilter(){
    const cardInfo=[
        {image:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQz3fIWD8EQsvcN8vjqj3RBFXOt0Ybr1C5v5g&usqp=CAU",title:"Lebron James",text:"The worst"},
        {image:"https://assets.bwbx.io/images/users/iqjWHBFdfxIU/iRvzLV4Dj3Y4/v0/1200x-1.jpg",title:"James Harden",text:"Meh"},
        {image:"https://i.insider.com/5a0dc09a3dbef484008b67e7?width=1000&format=jpeg",title:"Speph Curry",text:"Good"},
        {image:"https://depor.com/resizer/Wtf5Y1e8fWd5zRd3Do6yRgV58Fg=/580x330/smart/filters:format(jpeg):quality(75)/cloudfront-us-east-1.images.arcpublishing.com/elcomercio/IKJYQ4ZQ7RFWZFE57TNEBKD5SQ.jpg",title:"Michael Jordan",text:"GOAT"},
    ]
    const renderCard=(card,index)=>{
        return(
            <ul className="card">
                <li><img src={card.image}></img></li>
                <li><p className="tittle-card">{card.title}</p></li>
                <li><p className="text-card">{card.text}</p></li>
            </ul>
        )
    }
    
    const [searchTerm, setSearchTerm] = useState('');

    return (
        <div>
            <input
                type="text"
                placeholder="Search..."
                onChange={ (event) => setSearchTerm(event.target.value)}
            />
            <div className="container">
                {cardInfo.filter((val)=>{
                    if (searchTerm==""){
                        return val
                    }

                    else if (val.title.toLocaleLowerCase().includes(searchTerm.toLocaleLowerCase())){
                        return val
                    }
                }).map(renderCard)}
            </div>
        </div>
        )
}
export default ProductsFilter

use createOrder method return orderID and turn off Paypal shipping at the same time, paypal buttons

how can merge this two way,
I have a need, return orderID and turn off Paypal shipping at the same time,
The First Method

createOrder: function (data, actions) {
return actions.order.create({
  purchase_units: [{
    amount: {
      value: '0.03'
    }`enter code here`
  }]
})

}

The Second Method,
orderId: 95F21375EK077912C,
this OrderId from server

createOrder: function (data, actions) {
  let orderId = "95F21375EK077912C"
  return orderId
}

How to adjust spaces between points in chart js?

I am trying to make a line chart by using chart.js. But I facing a problem. I want to control the space between points, but the chart.js makes it equal.

Here is my code:

<canvas id="myChart"></canvas>

<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.js" integrity="sha512-OD9Gn6cAUQezuljS6411uRFr84pkrCtw23Hl5TYzmGyD0YcunJIPSBDzrV8EeCiFxGWWvtJOfVo5pOgB++Jsag==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

<script>
var ctx = document.getElementById("myChart");

var points = [1,1,9,9.3];
var Dates = ["Dec 29th", "jan 10th", "Feb 21st", "Feb 25th"];

var myChart = new Chart(ctx, {
  type: "line",
  data: {
    labels: Dates,
    datasets: [
      {
        label: "My chart",
        data: points,
        backgroundColor: "black",
        borderColor: "blue",
        borderWidth: 3,
        fill: false,
        lineTension: 0.4,
      }
    ]
  },
  
  options: {
    legend: {display: false},
    scales: {
      yAxes:[{
        ticks: {
            min:1,
            max: 9.9,
                  
            callback: function(value, index, values) {
                return '$' + value;
            }
        }
      }],
      
    },
     elements: {
        point:{
            radius: 0
        }
    }
  }
});
</script>

Here is the result of my code:
enter image description here

But I want the big space in middle like this:
enter image description here

How can I make the big space between point 3 and point4, please?

Detecting if user use the same device with JavaScript

Is there a way to detect if a user is using the same device/browser on a web page e.g. If the user enters the site in the morning with a laptop, the client-side sends a token to the server and if the user enters the site in the evening with the same laptop or device, the client-side must send the same token. 

The possibility that comes to mind is saving a token in a cookie and getting it back later, but it is very unsafe.

Calculating a sum in Javascript that is more than 16 digits (without rounding)? [duplicate]

I’m a noob coder and I’m trying to make a small app that generates random math problems with x amount of digits. It works fine until I try something like multiplying two 9 digit numbers.

Here is the block of code that calculates the two randomly generated numbers:

let sum1 = 0
let sum2 = 0
function answer() {
let theAnswer = 0
scoreOnce = 1
if (operatorEl.textContent === "+") {
    theAnswer = sum1 + sum2
    fullsum.textContent = theAnswer
} else if (operatorEl.textContent === "-") {
    theAnswer = sum1 - sum2
    fullsum.textContent = theAnswer
} else if (operatorEl.textContent === "*") {
    theAnswer = sum1 * sum2
    fullsum.textContent = theAnswer
} else if (operatorEl.textContent === "÷") {
    theAnswer = sum1 / sum2
    fullsum.textContent = theAnswer
}
}

And this is how I generate the numbers (9 digit numbers in this case):

function generate9() {
sum1 = Math.floor(Math.random() * (999999999 - 100000000 +1)) + 100000000
    topNum.textContent = sum1
    sum2 = Math.floor(Math.random() * (sum1 - 100000000 +1)) + 100000000
    botNum.textContent = sum2
    fullsum.textContent = "____"
    fullsum.style.color = "#FFFFFF"
    inputEl.value = ''
    scoreOnce = 0
}

HTML & CSS animation not working when added to website

I have a animation made in HTML & CSS on codepen.io, here’s the animation – https://codepen.io/akshzyx/pen/OJOqpav.

It works fine on codepen but when tried to used in personal website, animations stop working.

Eyes blinking is the only thing that works on website. Tried in 2-3 browsers, same everywhere.

How can I fix this?

HTML Code

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="robot" x="0" y="0" viewBox="0 0 600 800" enable-background="new 0 0 600 800" xml:space="preserve">
  <ellipse id="shadow" opacity="0.4" fill="#2C3332" cx="300" cy="703.4" rx="89" ry="30.6"/>
  <g id="left_arm">
    <path fill="#BABEB7" d="M184 430.9c-44-18.9-84.8 18-94.2 44.1 -10.9-3.3-22.1-1.3-28.8 5.5 -1 1-1.8 2-2.6 3.2 -1.9 2.1-4.5 5.2-6.2 8.3 -5.8 10-2.3 23.1 7.7 32.4l3.8-3.7 5.7-7.1 -3.8 3.8c-6.8-6.4-10.6-14.6-10.5-22.3 -0.1 7.7 3.7 15.9 10.5 22.2l3.8-3.7c-4.8-5.1-6.7-11.7-4.8-17.3 5.6-3.5 13.8-3.4 21 0.8 8.7 5 13 14.3 10.5 21.7 -2.4 1.5-5.3 2.4-8.4 2.5l-5.7 7.1 0.1 6c8.5 0.8 16.5-1.6 21.7-6.8 1.2-1.2 6.3-7.3 7.2-8.8 0 0 0 0 0-0.1 0.6-0.8 1.1-1.5 1.6-2.4 5.5-9.5 2.6-22.1-6.4-31.2 13.2-12.9 33.1-25.2 48.8-9.1C156.5 477.4 189.1 433.1 184 430.9z"/>
    <path fill="#DCE0DA" d="M106.3 485c-2.4-2.4-5.2-4.6-8.4-6.5 -2.6-1.5-5.3-2.7-8.1-3.5 -10.9-3.3-22.1-1.3-28.8 5.5 -1.2 1.2-2.3 2.6-3.2 4.1 -5.8 10-2.3 23.3 7.7 32.5l3.8-3.7c-4.8-5.1-6.7-11.7-4.8-17.3 0.3-0.8 0.6-1.6 1.1-2.4 4.1-7.1 14.2-9.2 23.3-5.1 0.8 0.3 1.5 0.7 2.3 1.2 1.9 1.1 3.6 2.4 5.1 3.9 5.9 5.9 7.9 14 4.3 20.2 -1.1 2-2.7 3.5-4.6 4.7 -2.4 1.5-5.3 2.4-8.4 2.5l0.1 6c9.4 0.9 18.2-2.1 23.3-8.7 0.6-0.8 1.1-1.5 1.6-2.4C118.1 506.6 115.2 494.1 106.3 485z"/>
  </g>
  <g id="right_arm">
    <path fill="#DCE0DA" d="M547.7 492c-1.8-3-4.3-6.1-6.2-8.3 -0.8-1.2-1.6-2.2-2.6-3.2 -6.7-6.8-17.8-8.8-28.8-5.5 -9.3-26.1-50.2-63-94.1-44.1 -5.1 2.2 27.5 46.5 28.9 45 15.6-16.1 35.6-3.8 48.8 9.1 -8.9 9.1-11.9 21.6-6.4 31.2 0.5 0.8 1 1.6 1.6 2.4 0 0 0 0 0 0.1 0.9 1.6 6 7.6 7.2 8.8 5.2 5.3 13.2 7.7 21.7 6.8l0.1-6 -5.7-7.1c-3.1-0.1-6-1-8.4-2.5 -2.5-7.5 1.8-16.7 10.5-21.7 7.2-4.2 15.5-4.2 21-0.8 1.9 5.6-0.1 12.2-4.8 17.3l3.8 3.7c6.8-6.3 10.6-14.5 10.5-22.2 0.2 7.8-3.6 16-10.5 22.3l-3.8-3.7 5.7 7 3.8 3.8C550 515.1 553.5 502 547.7 492z"/>
    <path fill="#BABEB7" d="M547.7 492c-3.1-5.4-8.8-11-8.8-11s0 0 0 0c1.2 1 2.3 2.4 3.2 3.9 5.8 10 2.3 23.1-7.7 32.4l-3.8-3.7 5.7 7 3.8 3.8C550 515.1 553.5 502 547.7 492z"/>
    <path fill="#BABEB7" d="M489 518.6C489 518.6 489 518.6 489 518.6c0.9 1.6 6 7.7 7.2 8.9 5.2 5.3 13.2 7.7 21.7 6.8l0.1-6 -5.7-7.1 -0.1 6C502.9 528.2 494.1 525.1 489 518.6z"/>
    <path fill="#BABEB7" d="M534.4 493.8c-4.1-7.1-14.2-9.2-23.3-5.1 -0.8 0.3-1.5 0.7-2.3 1.2 -1.9 1.1-3.6 2.4-5.1 3.9 -5.9 5.9-7.9 14-4.3 20.2 1.1 2 2.7 3.5 4.6 4.7 -2.5-7.5 1.8-16.7 10.5-21.7 7.2-4.2 15.5-4.2 21-0.8C535.2 495.4 534.8 494.6 534.4 493.8z"/>
  </g>
  <g id="robot_main">
    <g id="body">
      <path id="SVGID_3_" fill="#BABEB7" d="M137.4 525.6c0-47.9 60.7-219.3 162.6-219.3 101.9 0 162.6 171.9 162.6 219.3 0 47.5-137.9 56.4-162.6 56.4C275.3 582.1 137.4 573.5 137.4 525.6z"/>
      <path fill="#DCE0DA" d="M200.8 522.8c0.1-0.4 0.3-0.8 0.4-1.2C201 522 200.9 522.4 200.8 522.8z"/>
      <path fill="#DCE0DA" d="M200.2 524.6c0.1-0.4 0.2-0.8 0.3-1.1C200.5 523.8 200.3 524.2 200.2 524.6z"/>
      <path fill="#DCE0DA" d="M201.3 521.1c0.2-0.6 0.4-1.1 0.7-1.6C201.8 520 201.6 520.6 201.3 521.1z"/>
      <path fill="#DCE0DA" d="M198.9 534.8c0-0.7 0-1.4 0-2C198.9 533.4 198.9 534.1 198.9 534.8z"/>
      <path fill="#DCE0DA" d="M199.8 526.4c0.1-0.4 0.2-0.8 0.3-1.2C200 525.6 199.9 526 199.8 526.4z"/>
      <path fill="#DCE0DA" d="M438.8 437.2c-21.1 18.1-64.2 43.3-140.1 43.3 -67.7 0-86.4 14.8-96.7 39.2 -1.9 4.5-3.1 9.7-3.1 15.1 0 13.9 7.7 29.5 29.4 40.2 0 0 0 0 0 0 -0.3 0-0.5 0-0.8 0 0.3 0.1 0.5 0.3 0.8 0.4 31.4 5.2 61.4 6.7 71.7 6.7 24.7 0 162.6-8.9 162.6-56.4C462.6 508.1 454.3 473.7 438.8 437.2z"/>
      <path fill="#DCE0DA" d="M199 532.7c0-0.6 0.1-1.3 0.1-1.9C199.1 531.4 199 532.1 199 532.7z"/>
      <path fill="#DCE0DA" d="M199.2 530.3c0.1-0.5 0.1-1 0.2-1.4C199.3 529.4 199.2 529.9 199.2 530.3z"/>
      <path fill="#DCE0DA" d="M199.4 528.3c0.1-0.4 0.1-0.8 0.2-1.3C199.6 527.5 199.5 527.9 199.4 528.3z"/>
      <g id="percent_meter">
        <path fill="#EAECE8" d="M370.5 535.3c-0.1 0-0.2 0-0.4 0.1 -18 2.8-41.2 5-70 5 -44.7 0-75.9-5.2-95.4-10.1 0 0 0 0 0 0 0 0 0 0 0 0l-5.8 3c0 0 0 0 0 0 20 5.4 53.1 11.5 101.2 11.5 87.8 0 125-20 125-20l-4.5-3C420.7 521.8 405.2 529.8 370.5 535.3z"/>
        <path fill="#EAECE8" d="M175.2 524.9C175.2 524.9 175.2 524.9 175.2 524.9 175.2 524.9 175.2 524.9 175.2 524.9z"/>
        <path fill="#EAECE8" d="M175 524.8C175 524.8 175 524.8 175 524.8 175 524.8 175 524.8 175 524.8z"/>
        <polygon fill="#BABEB7" points="420.5 503.6 416.2 505.2 418.5 513.6 420.7 521.8 425.2 524.8 "/>
        <polygon fill="#8F918D" points="179.3 504 174.8 524.7 179.3 521.7 182.4 510.3 183.7 505.6 "/>
        <path fill="#BABEB7" d="M175 524.8c-0.2-0.1-0.2-0.1-0.2-0.1S174.9 524.7 175 524.8z"/>
        <path fill="#BABEB7" d="M175.2 524.9c1 0.5 3.9 1.9 9 3.8 6.6 2.5 14.6 4.5 14.7 4.6C184.8 529.4 177.1 525.8 175.2 524.9z"/>
        <path fill="#BABEB7" d="M175.2 524.9c-0.1 0-0.1-0.1-0.2-0.1C175.1 524.8 175.2 524.9 175.2 524.9z"/>
        <path fill="#BABEB7" d="M175.2 524.9C175.2 524.9 175.2 524.9 175.2 524.9c1.9 0.9 9.5 4.5 23.7 8.4 0 0 0 0 0 0l5.8-3c0 0 0 0 0 0 -0.6-0.1-1.2-0.3-1.7-0.4 -16.2-4.2-23.7-8.1-23.7-8.1l-4.5 2.9c0 0 0.1 0 0.2 0.1 0 0 0 0 0 0C175.1 524.8 175.2 524.9 175.2 524.9z"/>
        <path fill="#2b8fca" d="M368.7 521.5l-0.4-4.2c-18.5 3.2-41.7 5.8-68.2 5.8 -39.1 0-71.1-5.6-91.6-10.4 -0.5 1.7-0.9 3.2-1.3 4.6 -1.3 5-1.9 8.6-2.6 13 19.5 4.9 50.7 10.1 95.4 10.1 28.8 0 52-2.1 70-5L368.7 521.5z"/>
        <path fill="#2479b0" d="M203 511.3c-12.4-3.2-19.3-5.8-19.3-5.8l-1.3 4.7 -3.1 11.5c0 0 7.5 3.9 23.7 8.1 0.6 0.1 1.1 0.3 1.7 0.4 0 0 0 0 0 0 0.6-4.4 1.3-8 2.6-13 0.4-1.4 0.8-2.9 1.3-4.6C206.6 512.2 204.8 511.8 203 511.3z"/>
        <path fill="#4C4C4C" d="M418.5 513.6l-2.3-8.4c0 0-17.5 6.8-47.1 12 -0.2 0-0.5 0.1-0.7 0.1l0.4 4.2 1.4 13.9c0.1 0 0.2 0 0.4-0.1 34.7-5.5 50.2-13.5 50.2-13.5L418.5 513.6z"/>
      </g>
    </g>
    <g id="head">
      <path fill="#EAECE8" d="M460.3 268.3c-3-50.9-81.4-57.8-160.3-57.8 -78.8 0-156.6 6.9-160 57.4 -1.6 9.5-2.1 21.5-2.1 36.4 0 53.6 3.2 89.9 25.1 109.7 2 1.8 4.1 3.6 6.3 5.3 37.4 29.4 98.6 43.4 130.7 43.4 32.5 0 93.3-13.9 130.7-43.2 2.3-1.8 4.4-3.6 6.5-5.5 21.9-19.8 25.2-56.1 25.2-109.7C462.4 289.6 461.9 277.7 460.3 268.3z"/>
      <path fill="#9BB2B0" d="M444.4 302.4c-0.1-16.4-0.8-35.6-5.7-44 -1.3-2.3-3.6-6.2-19.4-7 -9.8-0.5-20.2-1-30.7-1.4 -33.2-1.3-67.8-1.9-88.7-1.9 -20.9 0-55.4 0.7-88.7 1.9 -10.5 0.4-20.8 0.9-30.5 1.4 -15.8 0.8-17.9 4.5-19.3 7 -4.7 8.2-5.5 26.8-5.6 43 0.1 46.6 1.8 76.4 17.2 90.4 2.3 2.1 4.9 4.2 7.5 6.2 33.3 24.9 89.7 38.8 119.4 38.8 25.6 0 71.6-10.3 105.3-29 5.1-2.9 10-5.9 14.4-9.1 3-2.2 5.9-4.5 8.5-6.8 6.3-5.7 10.2-14.1 12.6-25.2 2.9-13.5 3.5-31.1 3.7-52.7 0-3.1 0-6.2 0-9.4C444.4 303.7 444.4 303 444.4 302.4z"/>
      <path fill="#A4BCB9" d="M388.7 249.9c-33.2-1.3-67.8-1.9-88.7-1.9 -20.9 0-55.4 0.7-88.7 1.9 -28.7 17.5-46.9 49.3-46.9 104 0 14.9 7.8 27.4 19.9 37.7 32.3 27.6 94.9 39 115.8 39 17 0 61.7-7.6 95.1-25.3 7.6-4 14.6-8.6 20.6-13.7 12-10.3 19.9-22.7 19.9-37.7C435.6 299.2 417.4 267.5 388.7 249.9z"/>
      <path fill="#EAECE8" d="M428.2 391.7c-2.6 2.4-5.4 4.6-8.5 6.8 -4.4 3.2-9.3 6.3-14.4 9.1 -33.7 18.7-79.7 29-105.3 29 -29.7 0-86.1-14-119.4-38.8 -2.7-2-5.2-4-7.5-6.2 -15.4-14-17.1-43.8-17.2-90.4 0 1 0 2 0 3 0 50 3.1 81.8 19.2 96.4 0.9 0.8 1.7 1.5 2.6 2.3 32.3 27.2 91.1 41.7 122.3 41.7 28.6 0 80.5-12.2 113.8-35.1 3-2.1 5.8-4.2 8.5-6.4 1-0.8 1.9-1.6 2.9-2.5 7.9-7.2 12.7-18.6 15.6-34.2C438.3 377.5 434.5 385.9 428.2 391.7z"/>
      <g id="eyes">
        <ellipse fill="#2C3332" cx="231" cy="316.7" rx="6.3" ry="17"/>
        <ellipse fill="#2C3332" cx="369" cy="316.7" rx="6.3" ry="17"/>
      </g>
      <path fill="#DCE0DA" d="M460.3 268.3c-4-25.1-14.9-33.6-40-34.9 -41-2.2-92.3-3.3-120.3-3.3 -28 0-79.1 1.2-120.2 3.3 -25 1.3-35.8 9.8-39.8 34.5 -1.6 9.5-2.1 21.5-2.1 36.4 0 53.6 3.2 89.9 25.1 109.7 2 1.8 4.1 3.6 6.3 5.3 37.4 29.4 98.6 43.4 130.7 43.4 32.5 0 93.3-13.9 130.7-43.2 2.3-1.8 4.4-3.6 6.5-5.5 21.9-19.8 25.2-56.1 25.2-109.7C462.4 289.6 461.9 277.7 460.3 268.3zM444.4 313.7c-0.1 21.7-0.8 39.2-3.7 52.7 -2.8 15.6-7.6 27-15.6 34.2 -0.9 0.8-1.9 1.7-2.9 2.5 -2.7 2.2-5.5 4.4-8.5 6.4 -33.3 23-85.2 35.1-113.8 35.1 -31.2 0-90-14.5-122.3-41.7 -0.9-0.8-1.8-1.5-2.6-2.3 -16-14.6-19.2-46.4-19.2-96.4 0-1 0-2 0-3 0.1-16.2 0.9-34.8 5.6-43 1.4-2.5 3.5-6.2 19.3-7 9.7-0.5 20.1-1 30.5-1.4 33.2-1.3 67.8-1.9 88.7-1.9 20.9 0 55.5 0.7 88.7 1.9 10.5 0.4 20.9 0.9 30.7 1.4 15.8 0.8 18.1 4.7 19.4 7 4.8 8.4 5.6 27.6 5.7 44 0 0.7 0 1.3 0 1.9C444.4 307.5 444.4 310.6 444.4 313.7z"/>
      <g id="Robot_hat">
        <path fill="#DCE0DA" d="M354.3 220.3c0-29.9-24.3-54.2-54.2-54.2 -29.9 0-54.2 24.3-54.2 54.2 0 4.7 24.3 4.7 54.2 4.7C330.1 225 354.3 225 354.3 220.3z"/>
        <circle fill="#F0C419" cx="300.4" cy="207" r="8.1"/>
        <circle fill="#E64C3C" cx="324.7" cy="206" r="8.1"/>
        <circle fill="#4EBA64" cx="275.3" cy="206" r="8.1"/>
      </g>
    </g>
  </g>
</svg>

CSS Code

// --- Variables --- //
$hover_top: 80px;
$hover_bottom: 30px;

html, body {
  height: 100%;
}

body {
  background: #2a88c5  url(http://zmwlt.com/bucket/cz-20150128-what-color-2-bg.jpg) center center / 70%;
  position: relative;
}

#robot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate3d(-50%,-50%,0);
  max-width: 50vw;
  max-height: 80vh;
  margin: 0 auto;
}

#body{
        animation:hover 1.1s ease-in-out 0s infinite alternate}

        #head{
        animation:hover 1.1s ease-in-out 0.05s infinite alternate}

        #arms{
        animation:hover 1.1s ease-in-out 0.1s infinite alternate}

        #left_arm{
        transform-origin:center right; 
        animation:arms_bounce_left 1.1s ease-in-out 0s infinite alternate}

        #right_arm{
        transform-origin:center left; 
        animation:arms_bounce_right 1.1s ease-in-out 0s infinite alternate}

        #eyes ellipse{
        transform-origin:center center; 
        animation:eyes_blink 2s ease-out 0s infinite alternate}

        #shadow{
        transform-origin:center center; 
        animation:shadow 1.1s ease-in-out 0s infinite alternate}

// ---- Animations

@keyframes hover { 
    0% { transform: translate3d(0,$hover_top,0) }
    100% { transform: translate3d(0,$hover_bottom,0) }
}
@keyframes shadow { 
    0% {
        transform: translate3d(0,0,0) scale(1.5,1.2);  
        opacity: 0.4;
    }
    100% {
        transform: translate3d(0,0,0) scale(1,1);
        opacity: 0.2;
    }
}
@keyframes arms_bounce_left { 
    0% { transform: translate3d(0,$hover_top,0)rotate(0deg) }
    100% { transform: translate3d(0,$hover_bottom,0)rotate(-10deg) }
}
@keyframes arms_bounce_right { 
    0% { transform: translate3d(0,$hover_top,0)rotate(0deg) }
    100% { transform: translate3d(0,$hover_bottom,0)rotate(10deg) }
}
@keyframes eyes_blink { 
    0% { transform: scale(1,1) }
    90% { transform: scale(1,1) }
    95% { transform: scale(0.8,0) }
    100% { transform: scale(1,1) }
}

Unable to render new element in appendChild()

I’m currently trying to append new element into existing container, but for some reason, it does manage to show when I console.log() but the output wasn’t reflect to the DOM element. The code is available here.

export default function App() {
  var count = document.getElementsByClassName("numbering");
  var numbers = [];
  for (var i = 0; i < count.length; i++) {
    numbers.push(i + 1);
  }

  if (count.length > 0 && count !== "" && count !== undefined) {
    numbers.forEach((element) => {
      var newChild = document.createElement("div");
      newChild.className = "number-" + element;
      newChild.innerHTML = element;
      count[element - 1].appendChild(newChild);

      //does log the output 
      console.log(count[element - 1]);
    });
  }

  const Container = (props) => {
    return <div className="numbering">{props.children}</div>;
  };

  return (
    <div className="App">
      <Container>
        <div>Content 1</div>
      </Container>
      <Container>
        <div>Content 2</div>
      </Container>
    </div>
  );
}

Expectation:

Have a counter that counts how many .numbering class are appeared in element. Then based on the length, display the number accordingly.

Problem:

It doesn’t render as what I expected, but when I console.log() it, it does show.

Question:

May I know where I’ve done wrongly here? Or is there any alternative way to achieve what I’m trying to do here?

How do I calculate the price upon entering the quantity but also show its quantity when the add and minus button was clicked?

So what I wanted to do was to also calculate the unit price according to what number was entered. I was already able to update the quantity of the product and then calculate its unit price and also its total amount.

My problem now is how can I also allow the user to enter the quantity of the product. And also still retain the functionality to increase and decrease the product.

I have recreated this in codesandbox: https://codesandbox.io/s/add-to-cart-sampled-2-with-table-efqrhd?file=/src/Cart.js

const Cart = ({ cartItems, handleCartClearance, handleRemove, handleAdd }) => {
  const [inputQty, setInputQty] = useState(0);
  console.log(cartItems, "items");

  const totalAmount = cartItems.reduce(
    (price, item) => price + item.quantity * item.price,
    0
  );

  const handleSubmit = (e) => {
    e.preventDefault();
    console.log(cartItems, "order");
  };

  console.log(
    "test",
    cartItems.reduce((prev, item) => {
      if (!prev[item.id]) prev[item.id] = { ...item, nest: [] };
      prev[item.id].nest.push({ ...item });
      return prev;
    }, {})
  );

  return (
    <div>
      <form onSubmit={handleSubmit}>
        Order page
        {cartItems.length >= 1 && (
          <Button onClick={handleCartClearance}>Clear Orders</Button>
        )}
        {cartItems.length === 0 && <div>No Items in the cart</div>}
        <div>
          {Object.entries(
            cartItems.reduce((prev, item) => {
              if (!prev[item.id]) prev[item.id] = { ...item, nest: [] };
              prev[item.id].nest.push(item);
              return prev;
            }, {})
          ).map(([id, obj], idx) => (
            <TableContainer key={id + obj.color} component={Paper}>
              <Table aria-label="simple table">
                <TableHead>
                  <TableRow>
                    <TableCell align="center">
                      Product Name: {obj.name + " " + obj.size}
                    </TableCell>
                    <TableCell colspan={3}></TableCell>
                  </TableRow>
                  <TableRow>
                    <TableCell>Color</TableCell>
                    <TableCell>Qty</TableCell>
                    <TableCell></TableCell>

                    <TableCell>Unit Price</TableCell>
                  </TableRow>
                </TableHead>
                <TableBody>
                  {obj.nest.map((nest, idx) => (
                    <TableRow key={idx}>
                      <TableCell>{nest.color}</TableCell>
                      <TableCell>
                        <input
                          style={{ width: "1rem" }}
                          value={nest.quantity}
                        />
                      </TableCell>

                      <TableCell align="right">
                        <IconButton
                          onClick={(e) =>
                            handleAdd(
                              nest.id,
                              nest.prodName,
                              nest.price,
                              nest.size,
                              nest.cat,
                              nest.color
                            )
                          }
                        >
                          <AddIcon color="success" />
                        </IconButton>

                        <IconButton onClick={() => handleRemove(nest)}>
                          <RemoveIcon />
                        </IconButton>
                      </TableCell>
                      <TableCell>
                        {Number(nest.quantity) * Number(nest.price)}
                      </TableCell>
                    </TableRow>
                  ))}
                </TableBody>
              </Table>
            </TableContainer>
          ))}
         
          <div>
            <b>Total Amount :{totalAmount}</b>
          </div>
          {cartItems.length >= 1 && <Button type="submit">Save Order</Button>}
        </div>
      </form>
    </div>
  );
};

export default Cart;

Filling QC Google forms with many pages using Google Sheet- Only Last line of code not working i.e. UrlFetchApp

I have learned how to automate google form filling using google sheet and app script.After many trial and error to apply the concept and automate it on simple google forms i have created , it worked absolutely fine.

But when I applied on the google form( which i seriously want to automate), everything works fine except the last line of code i.e. UrlFetchApp which brings google form link and data together and submit the form using ” post” method but it’s not working.

When i commented this line rest of the code executed without any error but this line is making my effort fail. Kindly help.
I am attaching the code here along with google form link for which i have created this code.

https://docs.google.com/forms/d/e/1FAIpQLSc1uSOspwlen5Tcs0ccTxE4eia-scw3aVUwAsrVMdQBpk5ydA/viewform

PLEASE PLEASE HELP

    function QC_form_fill() {

  var wrkBk = SpreadsheetApp.getActiveSpreadsheet();
  var wrkSht = wrkBk.getSheetByName("Qdata");

var formURL =""
var formData =""

var sdate = "";
var stime = "";
var mname = "";
var board = "";
var eclas = "";
var batch = "";
var slecture = "";
var sfaculty = "";
var ati1 = "";
var ta1 = "";
var ta2 = "";
var ta3 = "";
var sopen = "";
var stengage = "";
var teachpace = "";
var chtresp = "";
var tmmanmnt = "";
var vomod = "";
var sgrammar = "";
var qppt = "";
var fhndwrtng = "";
var drssup = "";
var lobjective = "";
var expstyl = "";
var sflow = "";
var cntnacc = "";
var demos = "";
var ati2 = "";
var poll = "";
var la = "";
var hw = "";
var prlfcd = "";
var sggstn = "";

var noOfRows = wrkSht.getRange("AI1").getDisplayValue();

for (i=2; i<=noOfRows; i++)
{
  sdate =wrkSht.getRange("A"+i).getDisplayValue();
  stime =wrkSht.getRange("B"+i).getDisplayValue();
mname =wrkSht.getRange("C"+i).getDisplayValue();
board =wrkSht.getRange("D"+i).getDisplayValue();
eclas =wrkSht.getRange("E"+i).getDisplayValue();
batch =wrkSht.getRange("F"+i).getDisplayValue();
slecture =wrkSht.getRange("G"+i).getDisplayValue();
sfaculty =wrkSht.getRange("H"+i).getDisplayValue();
ati1 =wrkSht.getRange("I"+i).getDisplayValue();
ta1 =wrkSht.getRange("J"+i).getDisplayValue();
ta2 =wrkSht.getRange("K"+i).getDisplayValue();
ta3 =wrkSht.getRange("L"+i).getDisplayValue();
sopen =wrkSht.getRange("M"+i).getDisplayValue();
stengage =wrkSht.getRange("N"+i).getDisplayValue();
teachpace =wrkSht.getRange("O"+i).getDisplayValue();
chtresp =wrkSht.getRange("P"+i).getDisplayValue();
tmmanmnt =wrkSht.getRange("Q"+i).getDisplayValue();
vomod =wrkSht.getRange("R"+i).getDisplayValue();
sgrammar =wrkSht.getRange("S"+i).getDisplayValue();
qppt =wrkSht.getRange("T"+i).getDisplayValue();
fhndwrtng =wrkSht.getRange("U"+i).getDisplayValue();
drssup =wrkSht.getRange("V"+i).getDisplayValue();
lobjective =wrkSht.getRange("W"+i).getDisplayValue();
expstyl =wrkSht.getRange("X"+i).getDisplayValue();
sflow =wrkSht.getRange("Y"+i).getDisplayValue();
cntnacc =wrkSht.getRange("Z"+i).getDisplayValue();
demos =wrkSht.getRange("AA"+i).getDisplayValue();
ati2 =wrkSht.getRange("AB"+i).getDisplayValue();
poll =wrkSht.getRange("AC"+i).getDisplayValue();
la =wrkSht.getRange("AD"+i).getDisplayValue();
hw =wrkSht.getRange("AE"+i).getDisplayValue();
prlfcd =wrkSht.getRange("AF"+i).getDisplayValue();
sggstn =wrkSht.getRange("AG"+i).getDisplayValue();

 formURL ="https://docs.google.com/forms/d/e/1FAIpQLSc1uSOspwlen5Tcs0ccTxE4eia-scw3aVUwAsrVMdQBpk5ydA/formResponse?pageHistory=0,1"
 formData= "&entry.1809185170=" + sdate + "&entry.772722605=" + stime + "&entry.1721230767=" + mname + "&entry.1024240207=" + board + "&entry.1132896225=" + eclas +"&entry.134507089="+ batch + "&entry.1349051916=" + slecture + "&entry.15763511=" +sfaculty + "&entry.1915124723=" + ati1 + "&entry.1154530333=" + ta1 + "&entry.1450881147=" + ta2 + "&entry.1627300385=" + ta3 + "&entry.928964249=" + sopen + "&entry.103830616=" + stengage + "&entry.1749915137=" + teachpace + "&entry.1879781398=" + chtresp + "&entry.1210552578=" + tmmanmnt + "&entry.1659325247=" + vomod + "&entry.377007890=" + sgrammar + "&entry.1207703694=" + qppt + "&entry.960993930=" + fhndwrtng + "&entry.343485399=" + drssup + "&entry.1988728268=" + lobjective + "&entry.1019203670=" + expstyl + "&entry.222077844=" + sflow + "&entry.465124407=" + cntnacc +  "&entry.1299956408=" + demos + "&entry.956891355=" + ati2 + "&entry.60052266=" + poll + "&entry.125539625=" + la + "&entry.1193513376=" + hw + "&entry.705255491=" + prlfcd + "&entry.121026171=" +sggstn

  var finalURL = formURL + formData

  var options = {
     "method" : "post"
  };

     UrlFetchApp.fetch(finalURL, options);
}

}

Combine data from multiple objects into something readable by chartJS

I have some data like this (ignore that they all have the same date, they will normally have different dates):

[
    {
        "Raise Hand": 0,
        "Be Quiet": 1,
        "Ask For Help": 2,
        "Be Good": 3,
        "Comment": "four?",
        "date": "2022-03-05",
        "email": "[email protected]"
    },
    {
        "Raise Hand": 0,
        "Be Quiet": 1,
        "Ask For Help": 2,
        "Be Good": 3,
        "Comment": "four?",
        "date": "2022-03-05",
        "email": "[email protected]"
    },
    {
        "Raise Hand": 0,
        "Be Quiet": 1,
        "Ask For Help": 2,
        "Be Good": 3,
        "Comment": "four?",
        "date": "2022-03-05",
        "email": "[email protected]"
    },
    {
        "Raise Hand": 0,
        "Be Quiet": 1,
        "Ask For Help": 1,
        "Be Good": 1,
        "Comment": "a",
        "date": "2022-03-05",
        "email": "[email protected]"
    },
    {
        "Raise Hand": 0,
        "Be Quiet": 0,
        "Ask For Help": 0,
        "Be Good": 0,
        "Comment": "a",
        "date": "2022-03-05",
        "email": "[email protected]"
    },
    {
        "Raise Hand": 2,
        "Be Quiet": 2,
        "Ask For Help": 2,
        "Be Good": 2,
        "Comment": "asd",
        "date": "2022-03-05",
        "email": "[email protected]"
    },
    {
        "Raise Hand": 4,
        "Be Quiet": 4,
        "Ask For Help": 4,
        "Be Good": 4,
        "Comment": "asds",
        "date": "2022-03-05",
        "email": "[email protected]"
    },
    {
        "Raise Hand": 1,
        "Be Quiet": 2,
        "Ask For Help": 1,
        "Be Good": 0,
        "Comment": "asdsd",
        "date": "2022-03-05",
        "email": "[email protected]"
    },
    {
        "Raise Hand": 2,
        "Be Quiet": 1,
        "Ask For Help": 1,
        "Be Good": 3,
        "Comment": "asdsd",
        "date": "2022-03-05",
        "email": "[email protected]"
    },
    {
        "Raise Hand": 3,
        "Be Quiet": 2,
        "Ask For Help": 1,
        "Be Good": 2,
        "Comment": "ads",
        "date": "2022-03-05",
        "email": "[email protected]"
    },
    {
        "Raise Hand": 1,
        "Be Quiet": 2,
        "Ask For Help": 1,
        "Be Good": 1,
        "Comment": "asds",
        "date": "2022-03-05",
        "email": "[email protected]"
    },
    {
        "Raise Hand": 3,
        "Be Quiet": 2,
        "Ask For Help": 1,
        "Be Good": 2,
        "Comment": "asds",
        "date": "2022-03-05",
        "email": "[email protected]"
    }
]

And I need the data formatted into something like this with a new array for each ‘challenge’. X would be the date and Y would be the value of that ‘challenge’ on that particular day:

[{x:"2-22-22", y:2}, {x:"2-23-22", y:3}]

For example, it would have an array for ‘Raise Hand’, an array for ‘Be Quiet’, etc. but also be dynamic so I can add more ‘challenges’ or replace them later. I also don’t need date, email, and anything containing ‘comment’ taken out.
Raise Hand:

[{x:"2-22-22", y:0},{x:"2-23-22", y:0},{x:"2-24-22", y:1}, ect]

I’ve spent a few hours working on this and this is how far I’ve gotten:

function formatData() {
        let labels = []
        let keys = []
        //* Get keys
        for(let i = 0; i < data.length; i++) {
            for(let j = 0; j < Object.keys(data[i]).length; j++) {
                if(keys.indexOf(Object.keys(data[i])[j]) == -1) {
                    keys.push(Object.keys(data[i])[j])
                } 
            }
        }
        keys = reduceKeys(keys)
        
        let totalData = {}
        //* Get data for each key
        for(let i = 0; i < data.length; i++) {
            for(let j = 0; j < keys.length; j++) {
                //* If data[i] DOES NOT have keys[j] then do this
                if(Object.keys(data[i]).indexOf(keys[j]) != -1) {
                    //* Make new key with array if it does not exist
                    if(Object.keys(totalData).indexOf(keys[j]) == -1) {
                        totalData[keys[j]] = []
                    }
                    totalData[keys[j]].push(data[i][keys[j]])
                } else {
                    //* Make new key with array if it does not exist
                    if(Object.keys(totalData).indexOf(keys[j]) == -1) {
                        totalData[keys[j]] = []
                    }
                    //* If the key does not exist for that entry the put 0
                    totalData[keys[j]].push(0)
                }
                if(data[i].date == null || data[i].date == undefined) {
                    labels.push("Error: No date")
                } else {
                    labels.push(data[i].date)
                }
            }
        }
        console.log(totalData)
        console.log(labels)
        let outputData = []
        for(let i = 0; i < labels.length; i++) {
            let tempArr = []
            for(let j = 0; j < Object.keys(totalData).length; j++) {
                // Object.keys(totalData)
                let length = totalData[Object.keys(totalData)[j]].length
                for(let k = 0; i < )
            }
        }
    }

    //* remove comments, date, and email
    function reduceKeys(keyArr) {
        let output = []
        for(let i = 0; i < keyArr.length; i++) {
            let key = keyArr[i]
            if(key.toLowerCase().includes("comment") || key.toLowerCase().includes("date") || key.toLowerCase().includes("email")) continue
            output.push(key)
        }
        return output
    }

For more info on how I need the data formatted please look at this ChartJS docs page

How to separate fetch json data in React

I have a component with an array with an icon on it, and when I hover it over, it shows a div with data taken from the .json file. Now {data.strenght} renders all records to every div in the table row and every div looks the same on hovering over the icon. However, I want each div in the line to have the rendered content of the line as it is in the .json file. It is probably best to show it in the pictures.

For now is like this –
https://imgur.com/a/r0SDhy8

And it should be like this –
https://imgur.com/a/axPrBKR

How to do it?

React file

import react from "react";
import funcData from './testData.json';

    function TestFunc() {
        return (
            <div>
                {funcData.map(data => {
                    return (
                        <div key={data.id}>
                            <p>{data.strenght}</p>
                            <p>{data.health}</p>
                        </div>
                    )
                })}
            </div>
        );
    }

    export default TestFunc

JSON file

[
    {   
        "id": "1",
        "strenght": "20",
        "health": "15"
    },
    
    {
        "id": "2",
        "strenght": "555",
        "health": "5"
    }
]

I need to insert a value in an input field of an html form through javascript

HTML code

<div id="formulario">
    <h1>Posicionamento de CEO</h1>
    <form method="POST" style="width: 500px;">   

<div class="form-group">
   <label class="control-label  " for="id_identification">Identificação</label>
        
<div class=" ">enter code here
   <input type="text" name="identification" maxlength="256" class=" form-control" required="" id="id_identification">
</div>
</div>
<div class="form-group">
   <label class="control-label  " for="id_geolocation">Geolocalização</label>
       <div class=" ">
            <input type="text" name="geolocation" maxlength="100" class=" form-control" required="" id="id_geolocation">
</div
        <button type="button" onclick="start()" class="botao">Clique aqui para carregar 
         mapa</button>
    </form>
</div>

Javascript code that opens the map and captures the coordinate when I click on the map.

async function sendCoordsToMyApi(evt) {
    const coords = {
      lat: evt.latLng.lat(),
      lng: evt.latLng.lng()
    };

    console.log("vou enviar as coordenadas para api:", coords);
    alert(JSON.stringify(coords));

I need to enter the coordinate of the constant coords in the form in the input field id=”id_geolocation”
can you help me?

Moving ball at constant rate with angle

I am coding a small game in JavaScript and I am running into a math problem. I am trying to move an object towards the location that I just clicked. I am able to successfully do this with the code below. However I am having difficulty figuring out how to make the velocity constant. If I click close to the object that I am shooting from, the difference in the X/Y is small so dx/dy is slow. If I click far away the dx/dy has high values, so it moves a lot faster.

Here is the code that I have so far.

let relativeXY = relMouseCord(e);
let rise = relativeXY[1] - pOne.posY; //<-- This is the distance between the Y coords
let run = relativeXY[0] - pOne.posX; //<-- This is the distance between the X coords

let angle = Math.atan2(rise,run)*180/Math.PI 
console.log('tan angle ' + Math.tan(angle))
console.log('acutal angle '+ angle)

bullet.x = pOne.posX
bullet.y = pOne.posY

tempdx = run * 0.02     //Math.cos(angle)
tempdy = rise * 0.02    //Math.sin(angle)

I attempted to use cos and sin to normalize the speed and was able to make the velocity constant, but the direction of the projectile was incorrect.

Forward servlet response to React js

I have a complex requirement where I need to implement react js in a servlet jsp application.

The entire application developed in servlet jsp. I need to replace a particular functionality with React js.

Current functionality:
Click the link in a JSP page. It makes a servlet call and returns list of data that will be displayed in a table in the new JSP page.

New Requirement:
Click the link in a JSP page. It makes a servlet call and returns a json response, which needs to be consumed by React JS.

My concern is that the servlet can’t be a standalone service as it requires parameters coming from JSP request and fetch the details based on the request parameters and return json.

How do I achieve this as this seems to be complex?
The reason I want to implement react js is to have modern datatable features.