How to draw the 3D cube using React.Js and Three.Js with given JSON

I have JSON given below. Using this JSON need to create the 3D Box inside the 3D outline cube as shown in given image.

{
  "request_id": "614bd0e3de7f3745708a9fa4",
  "completed_time_UTC": "2022-02-06T20:56:19Z",
  "tracks": [
    {[![enter image description here][1]][1]
      "purchase_orders": ["1153511"],
      "vehicle_id": "be8c578a-c59c-4348-8148-50cfbeb5a6cd",
      "vehicle_type": "TRAILER_48T",
      "number_of_pallets": 14,
      "pallets": [
        {
          "purchase_orders": ["1153511"],
          "pallet_id": "fe76b310-d751-48eb-84f8-3ea47c7a94bd",
          "pallet_type": "BLANCA",
          "number_of_skus": 65,
          "skus": [
            {
              "sku": "17503006575454",
              "length": 32,
              "width": 27,
              "height": 26,
              "position": [0, 54, 26]
            },
            {
              "sku": "17503006575454",
              "length": 32,
              "width": 27,
              "height": 26,
              "position": [0, 0, 26]
            },
            {
              "sku": "17503006575454",
              "length": 26,
              "width": 27,
              "height": 26,
              "position": [64, 59, 78]
            },
            {},
            {
              "sku": "17503006575454",
              "length": 32,
              "width": 27,
              "height": 26,
              "position": [59, 54, 80]
            }
          ]
        },
        {
          "purchase_orders": ["1153511"],
          "pallet_id": "e693e8bd-e841-4a05-8912-aa0e837ba256",
          "pallet_type": "BLANCA",
          "number_of_skus": 65,
          "skus": [
            {
              "sku": "17503006575454",
              "length": 32,
              "width": 27,
              "height": 26,
              "position": [0, 0, 0]
            },
            {
              "sku": "17503006575454",
              "length": 32,
              "width": 27,
              "height": 26,
              "position": [0, 0, 26]
            },
            {},
            {
              "sku": "17503006575454",
              "length": 32,
              "width": 27,
              "height": 26,
              "position": [58, 54, 78]
            }
          ]
        }
      ]
    }
  ],
  "schemaName": "http://www.schema.org/logistics/1"
}

Can revealing module pattern be done without IIFE like this and serve same purpose?

My understanding of revealing module pattern is as follows:

CODE #1

const iifeModulePattern = (function () {
  const secretSeed = 999; // ← private
  const logSecretCode = function(){console.log(secretSeed+1)};
  return {methodForPublic : logSecretCode};
})();

iifeModulePattern.methodForPublic();

So far I hope I’m not wrong. My question is:

  1. Won’t the following Code #2 serve same purpose?
  2. If it does, why is Code #1 popular than Code #2?
  3. If it doesn’t, what’s the difference?

CODE #2

const modulePattern = () => {
  const secretSeed = 999; // ← private
  const logSecretCode = function(){console.log(secretSeed+1)};
  return {methodForPublic : logSecretCode};
};

modulePattern().methodForPublic();

I won’t store “secret” codes (like passwords) in this way. The above codes are just examples.

Console logging in HackerRank’s JavaScript

Just trying to run through the basic Hacker Rank practice tests.

They often give you an array of integers (arr) as input. Supposedly. However, using their “JavaScript(Node.js),” attempting to console.log(arr) at the outset of the function to verify the data type simply returns undefined.

Any array methods I use, whether syntactically correct or not, return undefined. Trying to console.log(“hello”) returns undefined. Its pretty infuriating that the solution is some basic difference. Lil help?

Thanks.

Angular : unable to show static html pages when hosted into server but works fine when run in local

In my angular project, I have placed few static html files(sampleText.html in this case) in src/assets/html folder. and in one of my component im trying to fetch and show it. Im using below code to do it. It works perfectly fine when im running npm start and im able to see the html part in localhost as desired. but when i build the same and host using aws amplify and it says “Please enable JavaScript to continue using this application.”
here is the frontend code:
ts file:

fetch(`../../assets/html/sampleText.html`).then(res => res.text()).then(data => {
  this.content =data;
})

in html im rendering as: <div [innerHTML]=”content”>

Display Data Chart.js with data in Html ( asp.net mvc using signalr )

I want to put data from HTML to data in chart.js. Could you show me the way to do that? Thank you very much.

This is my query code in HomeController.cs :

public JsonResult Get()
        {
            using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ValueConnection"].ConnectionString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand(@"SELECT [DeviceID],[Value] FROM [dbo].[Device1] WHERE [DeviceID]='PM1'", connection))
                {
                    command.Notification = null;

                    SqlDependency dependency = new SqlDependency(command);
                    dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);

                    if (connection.State == ConnectionState.Closed)
                        connection.Open();

                    SqlDataReader reader = command.ExecuteReader();

                    var listCus = reader.Cast<IDataRecord>()
                        .Select(x => new
                        {
                            DeviceID = (string)x["DeviceID"],
                            Value = (double)x["Value"],
                        }).ToList();
                    return Json(new { listCus = listCus }, JsonRequestBehavior.AllowGet);
                }
            }
        }

This is my text function to get data with signal :

<script type="text/javascript">
    $(function () {
        //Proxy created on the fly
        var cus = $.connection.cusHub;

        //Declare a function on the job hub so the server can invoke
        cus.client.displayValue = function () {
            getData();
        };

        //Start the connection
        $.connection.hub.start();
        getData();
    });

    function getData() {
        var $tbl = $('#tblValue');
        $.ajax({
            url: $("#Get").val(),
            type: 'GET',
            datatype: 'json',
            success: function (data) {
                $tbl.empty();
                $.each(data.listCus, function (i, model) {
                    $tbl.append
                        (
                            '<h2>' + model.Value + '</h2>'
                        );
                });
            }
        });
    }
</script>

And how I display data in HTML :

<h2 id="tblValue"></h2>

And now how can I put data from HTML to data in Chart.js code. Anyone can instruct me the way pls :

<script>
        var ctx = document.getElementById("percent-chart2");
        if (ctx) {
            ctx.height = 209;
            var myChart = new Chart(ctx, {
                type: 'doughnut',
                data: {
                    datasets: [
                        {
                            label: "My First dataset",
                            data: [ *, *, * ],
                            backgroundColor: [
                                '#00b5e9',
                                '#fa4251',
                                '#006400'
                            ],
                            hoverBackgroundColor: [
                                '#00b5e9',
                                '#fa4251',
                                '#006400'
                            ],
                            borderWidth: [
                                0, 0, 0
                            ],
                            hoverBorderColor: [
                                'transparent',
                                'transparent',
                                'transparent'
                            ]
                        }
                    ],
                    labels: [
                        'STATION 1',
                        'STATION 2',
                        'STATION 3'
                    ]
                },
                options: {
                    maintainAspectRatio: false,
                    responsive: true,
                    cutoutPercentage: 87,
                    animation: {
                        animateScale: true,
                        animateRotate: true
                    },
                    legend: {
                        display: false,
                        position: 'bottom',
                        labels: {
                            fontSize: 14,
                            fontFamily: "Poppins,sans-serif"
                        }

                    },
                    tooltips: {
                        titleFontFamily: "Poppins",
                        xPadding: 15,
                        yPadding: 10,
                        caretPadding: 0,
                        bodyFontSize: 16,
                    }
                }
            });
        }
</script>

There is a problem in making multiple select boxes with react and type scripts

I just made a multi-select box. Selecting one of the upper categories changes the lower category and table. I have made changes, but they should not be changed immediately, but should be modified to change when the search button is pressed. I’m attaching the code below. I wonder where to add the code. Please Help me. ….

import ~

const cx = className.bind(style);

const TableCard = styled(Card)`
  padding: 0;
  border-radius: 6px;

  table {
    border-radius: 6px;

    tr {
      border-radius: 6px;
    }
  }
`;

export default function ManageLog() {
    const [userInfo] = useUserInfo();

    const [userInfoLog, setUserInfoLog] = useState({
        name: "User Info",
        userSeq: 0
    });

    const [memberType, setMemberType] = useState({ 
        name: "Member Type", 
        memberSeq: 0
    });

    const [connectType, setConnectType] = useState({
        name: "Connect Type",
        connectSeq: 0
    });

    const [errorLog, setErrorLog] = useState({
        name: "Error Log",
        errorSeq: 0
    });
    
    const userInfoLogDefaultValue = useMemo(() => {
        return {
          name: "User Info",
          userSeq: 0
        };
      }, []);

      const memberTypeDefaultValue = useMemo(() => {
        return {
          name: "Member Type",
          memberSeq: 0
        };
      }, [userInfoLog.userSeq]);

      const connectTypeDefaultValue = useMemo(() => {
        return {
          name: "Connect Type",
          connectSeq: 0
        };
      }, [userInfoLog.userSeq]);

      const errorLogDefaultValue = useMemo(() => {
          return {
              name: "Error Log",
              errorSeq: 0
          };
      }, [userInfoLog.userSeq]);

    const col: ICol[] = [
        {
            title: "NO",
            dataIndex: 'no',
            width: "80px"
        },{
            title: "User ID",
            dataIndex: 'userId'
        },{
            title: "Member Type",
            dataIndex: 'memberType'
        },{
            title: "Company Name",
            dataIndex: 'companyName'
        },{
            title: "Change Type",
            dataIndex: 'changeForm',
            width: "148px"
        },{
            title: "Change Time",
            dataIndex: 'changeTime'
        }
    ];

    const loginCol: ICol[] = [
        {
            width: "80px",
            title: "NO",
            dataIndex: "no"
        }, {
            title: "User ID",
            dataIndex: "userId"
        }, {
            title: "Company Name",
            dataIndex: "companyName"
        }, {
            title: "IP Address",
            dataIndex: "ipAddress"
        }, {
            title: "Connect Time",
            dataIndex: "connectTime"
        }, {
            title: "Connect Type",
            dataIndex: "connectType",
            render: value => {
            if (value === "Login")
                return <span className={cx('loginText')}>{"Login"}</span>;
            else if (value === "Logout")
                return <span className={cx('logoutText')}>{"Logout"}</span>;
            else if (value === "LoginFail")
                return <span className={cx('loginFail')}>{"LoginFail"}</span>;
            else if (value === "session")
                return <span className={cx('sessionText')}>{"session"}</span>;
            else
                return
        }
        }
    ];

    const errorCol: ICol[] = [
        {
            width: "80px",
            title: "NO",
            dataIndex: "no"
        }, {
            title: "Error Time",
            dataIndex: "errorTime"
        }, {
            title: "Error Page",
            dataIndex: "errorPage"
        }, {
            title: "Error Type",
            dataIndex: "errorType"
        }
    ];

    const [searchValue, setSearchValue] = useState("");
    const [filterDate, setFilterDate] = useState([new Date(), new Date()]);
    const [searchOptions, setSearchOptions] = useState(null);
    const { isLoading, list, pagination } = useCondDate(searchOptions);
    const { page, setPage, setSize, total } = pagination;

    const handleSearchData = () => {
        console.log(userInfoLog, memberType, connectType, errorLog, filterDate, searchValue)
        setSearchOptions({
            userInfoLog: userInfoLog.userSeq,
            memberType: memberType.memberSeq,
            connectType: connectType.connectSeq,
            errorKind: errorLog.errorSeq,
            startDate: dateFormat(filterDate[0], "yyyy.MM.dd  HH:mm:ss"),
            endDate: dateFormat(filterDate[1], "yyyy.MM.dd  HH:mm:ss")
        })
    }

    return (
        <div>
            <Row justifyContent="flex-start">
                {(userInfo?.type === "aggregator_member" || userInfo?.type === "aggregator") &&
                <Col width={180} mr={10}>
                    <Select   
                        onSelect={v => setUserInfoLog(v)}
                        options={[
                            { name: "User Info", userSeq: 0},
                            { name: "Login Log", userSeq: 1},
                            { name: "Error Log", userSeq: 2}
                        ]}
                        defaultValue={userInfoLogDefaultValue}
                        selectKey="userSeq"
                        labelKey='name'                 
                    /> 
                </Col>
                } 

                <Col width={105} mr={10}>
                    {userInfoLog.userSeq === 0 ?
                    <>
                    <Select
                        onSelect={v => setMemberType(v)}
                        options={[
                            { name: "Member Type", memberSeq: 0},
                            { name: "Member", memberSeq: 1},
                            { name: "Manager", memberSeq: 2}
                        ]}
                        defaultValue={memberTypeDefaultValue}
                        selectKey="memberSeq"
                        labelKey='name'     
                    />
                    </>: null}

                    {userInfoLog.userSeq ===  1 ?
                    <>
                        <Select
                        onSelect={v => setConnectType(v)}
                        options={[
                            { name: "User ID", connectSeq: 0},
                            { name: "Connect Time", connectSeq: 1},
                            { name: "Connect Type", connectSeq: 2}
                        ]}
                        defaultValue={connectTypeDefaultValue}
                        selectKey="connectSeq"
                        labelKey='name'
                    /> 
                    </> : null}  

                    {userInfoLog.userSeq === 2 ?
                    <>
                        <Select 
                        onSelect={v => setErrorLog(v)}
                        options={[
                            { name: "Error Type", errorSeq: 0},
                            { name: "404", errorSeq: 1},
                            { name: "500", errorSeq: 2}
                        ]}
                        defaultValue={errorLogDefaultValue}
                        selectKey="errorSeq"
                        labelKey='name'
                        />
                    </> : null}
                </Col>

                <Col width={333} mr={10}>
                    <DatePicker onChangeDate={date => setFilterDate(date as [Date, Date])} 
                    disabled={false}
                    isRange={true}
                    format={"yyyy.MM.dd HH:mm:ss"} />
                </Col>
                <Col width={150} mr={5}>
                    <BorderedMiniInput
                        value={searchValue}
                        onChange={setSearchValue}
                        placeholder=" ID"
                    />
                </Col>
                <Col>
                    <Button
                        primary={true}
                        label={""}
                        size="large"
                        icon={"icon_input_search2"}
                        iconSize={18}
                        bgColor={"#98A3C7"}
                        hoverColor={"#C7C7E8"}
                        onClick={() => handleSearchData()}
                    />
                </Col>
                <Col style={{marginLeft: 'auto'}}>
                    <Button
                        label={"excel"}
                        size="large"
                        icon={"icon_xls"}
                        iconSize={18}
                        bgColor={'#fff'}
                        borderColor={"#24D0AF"}
                    />
                </Col>
                </Row>
                {!isLoading && <>
                    {userInfoLog.userSeq === 0 ?
                    <>
                        <Row>
                            <Col width={'100%'}>
                                <TableCard>
                                    <Table 
                                    data={[
                                        {
                                            no : 1,
                                            userId : "admin001",
                                            memberType : "ann",
                                            companyName : "ann",
                                            changeForm : "ann",
                                            changeTime : "2021.11.06 17:30:00"
                                        },{
                                            no : 2,
                                            userId : "admin002",
                                            memberType : "ann",
                                            companyName : "ann",
                                            changeForm : "ann",
                                            changeTime : "2021.01.06 17:30:00"
                                        },{
                                            no : 3,
                                            userId : "admin003",
                                            memberType : "ann",
                                            companyName : "ann(ann,
                                            changeForm : "ann",
                                            changeTime : "2021.01.31 17:30:00"
                                        },{
                                            no : 4,
                                            userId : "admin004",
                                            memberType : "ann",
                                            companyName : "ann)",
                                            changeForm : "ann",
                                            changeTime : "2021.02.06 17:30:00"
                                        },{
                                            no : 5,
                                            userId : "admin005",
                                            memberType : "ann",
                                            companyName : "ann",
                                            changeForm : "ann",
                                            changeTime : "2021.02.09 17:30:00"
                                        }
                                    ]} 
                                    col={col} 
                                    keyItem="no" 
                                    pagination />
                                </TableCard>
                            </Col>
                        </Row>
                    </> 
                    : null }
                    
                    {userInfoLog.userSeq === 1 ?
                    <>
                        <Row>
                            <Col width={'100%'}>
                            <TableCard>
                                    <Table 
                                    data={[
                                        {
                                            no : 1,
                                            userId : "admin001",
                                            companyName : "ann",
                                            ipAddress : "123.12.1.0",
                                            connectType : "ann",
                                            connectTime : "2021.11.06 17:30:00"
                                        }
                                    ]} 
                                    col={loginCol} 
                                    keyItem="no" 
                                    onPageChange={(page, perPage) => {
                                    setPage(page - 1);
                                    setSize(perPage);
                                    }
                                }
                                totalCount={total}
                                />
                            </TableCard>
                            </Col>
                        </Row>
                    </> : null}

                    {userInfoLog.userSeq === 2 ?
                    <>
                        <Row>
                            <Col width={"100%"}>
                                <TableCard>
                                    <Table 
                                        data={[
                                            {
                                                no : 1,
                                                errorTime : "2022.01.31 17:30:00",
                                                errorPage : "http://localhost8081/order/ordPwTrdList.do",
                                                errorType : "500"
                                            }, {
                                                no : 2,
                                                errorTime : "2022.02.06 17:30:00",
                                                errorPage : "http://localhost8081/order/ordPwTrdList.do",
                                                errorType : "404"
                                            }, {
                                                no : 3,
                                                errorTime : "2022.02.11 17:30:00",
                                                errorPage : "http://localhost8081/order/ordPwTrdList.do",
                                                errorType : "500"
                                            }, {
                                                no : 4,
                                                errorTime : "2022.02.13 17:30:00",
                                                errorPage : "http://localhost8081/order/ordPwTrdList.do",
                                                errorType : "500"
                                            }, {
                                                no : 5,
                                                errorTime : "2022.02.14 17:30:00",
                                                errorPage : "http://localhost8081/order/ordPwTrdList.do",
                                                errorType : "404"
                                            }
                                        ]}
                                        col={errorCol}
                                        keyItem="no"
                                        onPageChange={(page, perPage) => {
                                            setPage(page - 1);
                                            setSize(perPage);
                                        }}
                                        totalCount={total}
                                    />
                                </TableCard>
                            </Col>
                        </Row>
                    </> : null}
                </>}
        </div>
    )
}

Assign unique IDs to multiple template instances

I have a widget card template which will be used multiple times on a single page by the site’s content managers.

<div class="program-feature-card">
  <div class="elementor-cta__bg-wrapper">
    <div>
      Some content here...
    </div>
    <a id="click-for-more-info" class="" onclick="showHide()" href="#" >More Info</a>
    <div id="more-info" class="hide">
      More info here...
    </div>
</div>

The showHide function works to toggle the visibility for #more-info, but only as long as there’s a single instance of the widget on a page.

function showHide() {
  var element = document.getElementById("more-info");
  element.classList.toggle("hide");
  var element = document.getElementById("more");
  element.classList.toggle("more-active");
}

How can I assign unique IDs to each instance of the card?

How could extract context from a p-tag with selected option and also others word have no option to selecte?

I have a p-tag for showing the article which contains two types –
the word you don’t need to change and the word you can select in it.
enter image description here

    <div class="context">
        <p v-html="report_data" class="showTxt" id="showTxt" contenteditable="true"></p>
    </div>

and I wanna make a window for showing the result which user selected and also include others don’t need to change.

**
rr = $(‘#showTxt option:selected’).text()

this way would delect other word don’t need to change

r_content = document.getElementById(‘showTxt’).textContent

and this way would show everything include all option

thanks in advance

How to create an invoice for one-time payments with Stripe

So, I noticed the following behavior. When I create a checkout session with at least on recurring item (subscription), an invoice is automatically created. When the customer opens their Customer Portal, he will see the previous invoices for all subscriptions.

But, when I create a checkout session with no recurring items (one-time payment), invoice is not automatically created. Because of that, when customer opens Customer Portal, he will not see invoices for these orders.

I would like to show all customer invoices in the Customer Portal, both for recurring and one-time payments. So, how can I generate an invoice for one-time payment and link it to the checkout session?

Resizing table slow performance in electron app

I have the following js in my electron app to resize table columns:

const resizerMouseDown = (e) => {
    let th = e.target.parentNode
    let startOffset = th.offsetWidth - e.x

    window.addEventListener('mousemove', function (e) {
        if (th) {
            th.style.width = startOffset + e.x + 'px'
        }
    })

    window.addEventListener('mouseup', function () {
        th = undefined
    })
}

Example Table: (Arrays from json files populate the table contents)

<table>
    <thead>
        <tr>
            <th>
                <div>Column 1</div>
                <button on:mousedown={resizerMouseDown} class="resizer"></button>
            </th>
            <th>
                <div>Column 2</div>
                <button on:mousedown={resizerMouseDown} class="resizer"></button>
            </th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td><input type="text" /></td>
            <td><input type="text" /></td>
        </tr>
    </tbody>
</table>

When the table rows are more that 100, resizing the columns are very slow. I’m not even going to mention when the json files are huge (1000+ table rows).

Any suggestions to get better performance out of the code, or would this be a limitation of electron?

How to set, save, and retrieve HTML Id variables using exterior storage JS file? [closed]

Hey there, I am praying to the Stackoverflow gods right now. I have been nosing around the internet for over a week trying to grapple a slight understanding for js… and it has me beat. I am making a website for my girlfriends clothing resale company, and am now in the proccess of making a saved shopping cart(seemed easy) but i now find myself without resource, recycling the same links already highlighted in purple.

some problem context, i have three pages:
first is the posting/listing
second is my js storage
third is my cart(or any extra pages that will display ‘selected and incart’ items)…

bare with me here…

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width,
    initial-scale=1.0" />
    <title>AlexWeb</title>
    <link rel="stylesheet" href="(list_one)style.css" />

</head>
<body>
    <nav>
        <div class="logo">AllyRox</div>
        <div class="nav-items">
            <ul><li><a href="index.html">Home</a></li></ul>
            <ul><li><a href="/">LuvLush</a></li></ul>
            <ul><li><a href="/">About</a></li></ul> 
            <ul><li><a href="/">Contact Us</a></li></ul>
        </div> 

        <div class="nav-shopping">
            <ul><li><button onclick="window.location.href='cart.html';"><p>In Cart</p></button></li></ul>
            <div class="list-container"></div>
            <div class="fa">&#xf07a;</i>
            <span class='badge badge-warning' id='lblCartCount'></span>
        </div>
    </nav>
  <scipt src="storage.js">
    <section class="list" data-name="girlboss" data-price="5">
    <div class="title">
        <div class="title-box">
            <h1 class="product-name" id="name">Girl Boss</h1>
            </div>
        </div>
    </div>
        <div class="listing">
            <div class="container-form">
            <div class="slideshow-container">
                <!-- Full-width images with number and caption text -->
                <div class="mySlides fade">
                  <div class="numbertext">1 / 3</div>
                  <img class="img" value(src)="1" id="1" src="images/1.JPG" alt="img1">
                </div>
              
                <div class="mySlides fade">
                  <div class="numbertext">2 / 3</div>
                  <img class="img" src="images/2.JPG" alt="img2">
                </div>
              
                <div class="mySlides fade">
                  <div class="numbertext">3 / 3</div>
                  <img  class="img" src="images/3.JPG" alt="img3">
                </div>
              
                <!-- Next and previous buttons -->
                <a class="prev" onclick="plusSlides(-1)">&#10094;</a>
                <a class="next" onclick="plusSlides(1)">&#10095;</a>
              </div>
              <br>
              
              <!-- The dots/circles -->
              <div class="">
                <span class="dot" onclick="currentSlide(1)"></span>
                <span class="dot" onclick="currentSlide(2)"></span>
                <span class="dot" onclick="currentSlide(3)"></span>
              </div>

            <h2>sleak flexible bootcut black powerpants</h2>
    <div class="inputbox">
        <h5 post="weight" id="weight" value="7.00">7.00 : Under - 16 oz</h5>
        
    </div>
        <div class="column-bottom">
        <div class="add-button">
            <form class="add-button" method="post">
                <p><input type="submit" value="Add to cart" class="btn"></p></form>
        <div class="buy-button" action="checkout.html">
            <span class="price" post="price" id="price" value="60">$60</span>
          <button type="button" value="save" onclick="window.location.href='cart.html'";>BuyMe</button onclick="window.localStorage.getItem('img','price','weight')">
        </section>
    </scipt>
<script src="list-one.js" asnyc></script>
</body> 

—–>followed by my storage<——–

$( window ).load(function() {
    saveItem(); postInfo(); Counter(); setItem(); setCounter();
    removeItem(); clearAll(); 


    function saveItem() {
        var name = $("#post").val();
    var data = $("#value").val();
    localStorage.setItem(post, value);
    let post=postInfo();
    }


    function postInfo();
        post.addEventListener('click').addcart;{
            if (CheckBrowser(post, weight)) {
        
        var key = "name"; document.getElementById('name');
        var list = "<tr><th>name</th></tr>n";
        var i = 1;

        var key = "img"; document.getElementById('img').value(1);
        var list = "<tr><th>img</th><th>1</th></tr>n";
        var i = 1;

        var key = "price"; document.getElementById('Price').value('price');
        var list = "<tr><th>img</th><th>1</th></tr>n";
        var i = 1; 
        
         function Counter();        //Add weight to tally using weight shown in HTML listing.
            weight.addEventListener('click').addCounter;{
            clicks += 1;
            document.getElementById("weight").innerHTML = 'click';
        }

    JSON.parse(window.localStorage.getItem(post))
        function setItem()
            post.getElementById(post).setItem;
                if (CheckBrowser(post, weight));
                
        var key = "name"; document.getElementById('name');
        var list = "<tr><th>name</th></tr>n";
        var i = 1;
        
        var key = "img"; document.getElementById('img').value(1);
        var list = "<tr><th>img</th><th>1</th></tr>n";
        var i = 1;
        
        var key = "Price"; document.getElementById('Price').value('price');
        var list = "<tr><th>img</th><th>1</th></tr>n";
        var i = 1; 

        function setCounter()        //Set weight 'from' tally using weight shown in HTML listing.
                weight.setCounter(weight).setCounter;{
                    document.getElementById("weight").innerHTML = 'click';
                }

        function removeItem()
         {
            var name=document.forms.ShoppingList.name.value;
            document.forms.ShoppingList.data.value=localStorage.removeItem(name);
            doShowAll();
            }
            
            function clearAll() {
                localStorage.clear();
                doShowAll();
            }
            

    //Change an existing key-value in HTML5 storage.
function ModifyItem() {
    var name1 = document.forms.ShoppingList.name.value;
    var data1 = document.forms.ShoppingList.data.value;
    //check if name1 is already exists

//Check if key exists.
            if (localStorage.getItem(name1) !=null)
            {
              //update
              localStorage.setItem(name1,data1);
              document.forms.ShoppingList.data.value = localStorage.getItem(name1);
            }

    doShowAll();
}


            //For a more advanced feature, you can set a cap on max items in the cart.
    for (i = 0; i <= localStorage.length-1; i++) {
        key = localStorage.key(i);
        localStorage.myProperty="myValue";
            list += "<tr><td>" + key + "</td>n<td>"
                + localStorage.getItem(key) + "</td></tr>n";
        }


        //If no item exists in the cart.
    if (list == "<tr><th>Post</th><th>Value</th></tr>n") {
            list += "<tr><td><i>empty</i></td>n<td><i>empty</i></td></tr>n";
        }
        //Bind the data to HTML table.
        //You can use jQuery, too.


    } else {
        alert('Cannot save shopping list as your browser does not support HTML 5');
    }


}});

——–>and finally, the display.. i am so sorry..<———

<!DOCTYPE html>
<html lang="en">
<head>
<title>Whats-Crackin</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit">
<meta name="description" content="Shopping cart project with HTML5 and JavaScript">
<meta name="keywords" content="HTML5,CSS,JavaScript, html5 session storage, html5 local storage">
<meta name="author" content="style.css, Storagestyle.js">
<script type="text/javascript" src="storage.js"></script>
<document class="getElementById"><img src="" alt=""></document>
    <link rel="stylesheet" href="cart.css", />
</head>
<body>
    <nav>
        <div class="logo">AllyRox</div>
        <div class="nav-items">
            <ul><li><a href="index.html">Home</a></li></ul>
            <ul><li><a href="/">LuvLush</a></li></ul>
            <ul><li><a href="/">About</a></li></ul> 
            <ul><li><a href="/">Contact Us</a></li></ul>
        </div> 
    </nav>

<section class="list">     
    <div action="cart.html" class="container">
        <div onload="javascript:postInfo()" onload="javascript:Counter()">
            <script>
            JSON.parse(window.localStorage.getItem(post))
            function setItem()
                post.getElementById(post).setItem;
                    if (CheckBrowser(post, weight));
            </script>
        </div>
    </div>
        <div class="emptCart-btn">
            <ul><li>
            <input type="submit" name="delete" id="empty-cart" class="btn" value="Empty Cart" />
            </li></ul>
        </div>
        <div class="contShop-btn">
            <ul><li>
            <a href="index.html" class="btn">Continue Shopping</a>
            </li></ul>
        </div>
        <div class="checkout-btn">
            <ul><li>
            <a href="checkout.html" class="btn">Go To Checkout</a>
            </li></ul>
        </div>
    </ul>
    </div>
</div>   
</section>

—> if im not just a sad port belly pig, like princess laya your my only hope, and like dorthy clicking my red slippers i just want to follow the yellow brick road. this is my first project, and hopefully smooth sailing after someone helps me here. thank you, ill be here… huddled in the corner.

onChange Not Updating State At Correct Time

I’m trying to save the value of the input field to state. When the defaultValue is ‘projectName’, and I delete the word ‘Name’ from the input field, I want the state to update so that the defaultValue is ‘project’. When I console.log e.target.value in the onChange, I can see the change happening when I make the deletion, and my code in the onChange is saving the value to state, but unfortunately, the state does not update. Any thoughts as to why?

Here is a Code Sandbox: https://codesandbox.io/s/amazing-river-o15h4?file=/src/Child.js

… And here is a screenshot of the console.log in the onChange and the setState call not updating:enter image description here

App.js

import "./styles.css";

import Child from "./Child";

export default function App() {
  const thisIsState = {
    id: 1,
    projectName: "projectName",
    description: "description"
  };

  return (
    <div className="App">
      <Child project={thisIsState} />
    </div>
  );
}

Child.js

import { useState, useEffect } from "react";
import "./styles.css";

export default function Child(props) {
  console.log(props);
  const [state, setState] = useState({
    projectName: "",
    description: ""
  });

  let project = props.project;
  let errors = props.errors;
  useEffect(
    (state) => {
      setState({
        ...state,
        projectName: project.projectName,
        description: project.description
      });
      console.log("useEffect1 state: ", state);
    },
    [project, errors]
  );

  const onChange = (e) => {
    console.log("e.target.value in onChange: ", e.target.value);
    setState((state) => ({
      ...state,
      [e.target.name]: e.target.value
    }));
    console.log("onChange() state: ", state);
  };
  return (
    <div className="App">
      <form>
        <input
          type="text"
          placeholder="Project Name"
          name="projectName"
          defaultValue={props.project.projectName}
          onChange={onChange}
          style={{ marginBottom: "15px" }}
        />
        <br />
        <input
          type="text"
          placeholder="Project Name"
          name="projectDescription"
          defaultValue={props.project.description}
          onChange={onChange}
        />
      </form>
    </div>
  );
}

How to check if array contains other array objects [JS]

I’m trying to make a basic javascript algorithim. Im trying to make a basic ‘enjoyability’ scale.
Basically if the array “tags”, contains an object from “interests” add 1 to enjoyability. If the array “tags” contains an object from “dislikes” subtract 1 from enjoyability.
How can I do this?

const fs = require('fs');
var interests = ["gaming", "coding", "dogs", "food"];
var dislikes = ["cats", "school", "work", "politics"];
var tags = ["gaming", "dogs", "school", "food", "coding"];
var enjoyability = 0;
var enjoyable = 0;
var PosOrNeg = 0;
var isIn;
const intr = tags.some(r=> interests.indexOf(r) >= 4)
const disl = tags.some(r=> dislikes.indexOf(r) >= 0)

if (intr == true) {
    console.log('a')
}

function run() {
    
console.log('a'+enjoyability)
    console.log(tags.includes())
    if (enjoyability >= 0) {
        enjoyable = 0;
        console.log("yes")
    } else {
        enjoyable < 0;
        console.log("no")
    }
}
console.log(intr)
console.log(disl)
console.log(enjoyable)
run()