A javascript Function object cannot be called, can?

This is weird! I am struggling hard with the problem that javascript Proxy handler’s apply trap does not get the Proxy itself passed as an argument, only the naked function. But I need to pass along some metadata to use for re-wrapping function results.

So I thought I could just use Object.create to make a specialization of the function to which I could stick additional information. But that doesn’t work! And that’s surprising!

function test() { return "hi!"; }
test()                                    // 'hi!'
test1 = test                              // ƒ test() { return "hi!"; }
test1()                                   // 'hi!'
test2 = Object.create(test)               // Function {}
test2()                                   // Uncaught TypeError: test2 is not a function
test3 = new Function([], "return 'lo!';") // ƒ anonymous() { return 'lo!'; }
test3()                                   // 'lo!'
test2.prototype.constructor()             // 'hi!'
test3.prototype.constructor()             // 'lo!'
Object.getPrototypeOd(test2)()            // 'hi!'

So I guess I can could help myself evaluate a function if I unwrapped it somehow:

while(fn instanceof Function && typeof fn != 'function')
    fn = Object.getPrototypeOf(fn);

But that doesn’t work if I just want to call it, i.e., make my special function transparent to any downstream user.

OK, here is a workaround, instead of using Object.create(fn) I can just wrap it:

fn = function() { return fn.apply(this, arguments); }

now I can stick my special metadata to this fn and I can also wrap it in a Proxy.

But my question is: what is the meaning of Object.create(fn) if you don’t get an actual callable function?

How can i split box shadow by comma

There are box-shadow:
inset rgba(145, 19, 19, 1) 2px 0px 8px 0px, rgba(0, 19, 29, 0.2) 10px 29px 8px 0px,inset #f913e6 0px 0px 8px 0px

I need the following comma-separated value:
["inset rgba(145, 19, 19, 1) 2px 0px 8px 0px", "rgba(0, 19, 29, 0.2) 10px 29px 8px 0px" , inset #f913e6 0px 0px 8px 0px]

How can achieved it using regex pattern (JavaScript)

How do you translateX by x amount relative to it’s position in Vanilla JS?

I’m creating a carousel component in React and I’m having trouble implementing the next, and previous functionality:

  const onClickPrevious = () => {
    const box = opstionsListRef.current.getBoundingClientRect();
    opstionsListRef.current.style.transform = `translateX(${box.x - 300}px)`;
  };

  const onClickNext = () => {
    const box = opstionsListRef.current.getBoundingClientRect();
    opstionsListRef.current.style.transform = `translateX(${box.x + 100}px)`;
  };

I had to decrement by 300 just to have a more decent translateX, but it still not working 100% correctly.

Searching by Filename and by Category

Hi fellow developers. I’m creating a webpage to display documents. I’m trying to search
by ‘filename’ and by ‘category’. I have a dropdown for selecting file categories and a
search input. So I created two event listeners, one to search by file name and the other
to search by category. I have many categories and I want to use the same function to
search through all my categories.

Here is my difficulties:
I have one search input and my two event listers use the same input
reference(id=”search”). So at the moment I can only search by filename or by category

Here is my HTML code:


<section id="top1">
    <div class="top-left">
        <span><i class="mdi mdi-cloud-search"></i></span>
        <div class="dropDown">
              <select id="selectbox1" onchange="selectOption(this.value)">
                    <option value="file_name" class="file_name">File Name</option>
                    <option value="probation" class="probation">Probation 
                Review</option>
                    <option value="signed" class="signed">Signed Policies</option>
                    <option value="sick" class="sick">Sick Notes</option>
                    <option value="family" class="family">Family Responsibility Leave</option>
                    <option value="private" class="private">Private</option>
                    <option value="warnings" class="warnings">Warnings</option>
                    <option value="assets" class="assets">Assets</option>
                    <option value="certificates" class="certificates">Certificates</option>
                </select>
        </div>
        <div class="search">
            <input id="search" type="text" placeholder="search" >
        </div>
    </div>
    <div class="upload">
        <button>Upload Files</button>
    </div>
</section>

<!-- #1documents row -->
<section class="reuse">
    <h3>Probation Reviews</h3>
    <div class="documents first-section" id="probation-review">
        
    </div>
</section>

<!-- #2documents row -->
<section class="reuse ">
    <h3>Signed Policies</h3>
    <div class="documents first-section" id="signed-policies">
    </div>
</section>

<!-- #3documents row -->
<section class="reuse">
    <h3>Sick Notes</h3>
    <div class="documents first-section" id="sick-notes">
    </div>
</section>

I created an array in the js file for my documents and looped them to display.
Here is the code below.

    /*Sick Notes*/

 const sick_note_arry = [
  { path: "https://documentcloud.adobe.com/view-sdk-demo/PDFs/Bodea Brochure.pdf", title: "Clinics", sub_title: "1 Jan 2022 10:15" },
  { path: "assets/textFiles/sample3.txt", title: "Doctors", sub_title: "1 Jan 2022 10:15" },
  { path: "https://media.geeksforgeeks.org/wp-content/cdn-uploads/20210101201653/PDF.pdf", title: "Dr Appointment", sub_title: "1 Jan 2022 10:15" },
  // "assets/wordDocs/TeamMeeting.docx",
]
const mainCard = document.getElementById("sick-notes");

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

  const newCard = document.createElement("div");
  newCard.classList.add("myDocs");
  mainCard.classList.add("first-section");

  cardHtml = `
 <div class="innerDoc">
 <iframe src="${sick_note_arry[i].path}" alt="" width='200px' height='200px' ></iframe>
 <h5>${sick_note_arry[i].title}</h5>
 <h6>${sick_note_arry[i].sub_title}</h6>
 </div>
 `;

  mainCard.appendChild(newCard);
  newCard.innerHTML = cardHtml;
}
/*End Of Sick Notes*/

Here is my event listener for searching by file name.

   const get_input =  document.getElementById("search");
   const inner_div = document.getElementsByClassName("myDocs");
   get_input.addEventListener("keyup", (event)=>{
   const valueKey = event.target.value;
   const search_items =  document.querySelectorAll(".myDocs h5");

  for (var i = 0; i < search_items.length; i++) {
    const myElements = search_items[i].innerHTML;
    
    if (myElements.trim().toLowerCase().indexOf(valueKey.trim().toLowerCase()) > -1) {
      inner_div[i].style.display = "block";
  } else {
      inner_div[i].style.display = "none";
  }
  }
})

And here is the event for searching by category:

const inner_diver = document.querySelectorAll("#probation-review .myDocs");
get_input.addEventListener("keyup", (e) => {
const valueKey = e.target.value;

for (var i = 0; i < inner_diver.length; i++) {
const myElements = inner_diver[i].innerHTML;

if (myElements.trim().toLowerCase().indexOf(valueKey.trim().toLowerCase()) > -1) {
  inner_diver[i].style.display = "block";
} else {
  inner_diver[i].style.display = "none";
}

}
})

My desired outcome is to have one function for searching through all categories. I’m a
beginner so I hope my question is clear. I would appreciate it if the solution could be
in javascript or jquery. Thank you in advance.

Extracting form data into a device using react and node.js

enter image description here

I Need a little help with the task, as I am using react and node.js for the first time, in here I want the user to browse a path from there device then fill the form and submit it. After submitting the form should be saved inside a choosen path as a json file. So far I have created a form but it’s allowing the user to upload a file while I want the user to select the path to save the form into that set path

This is my client side code

    import React from 'react';
    import Form from 'react-bootstrap/Form';
    import  './styles/main.scss';
    function DataExtractor() {
      const updateList= function(){
        var input = document.getElementById('selectFile');
        var output = document.getElementById('fileList');
        output.innerHTML = '<span>'
        for(var i = 0; i<input.files.length;++i){
          output.innerHTML += '<span>' + input.files.item(i).name + '</span>';
        }
        output.innerHTML += '</span>';
      }
     return (
    <>
      <div id="container">
        <div className='contact-info'>       
        </div>
        <form>
        <h1>
        Tread Data Extractor
      </h1>
          <div className='col'>
          <div className='form-group'>
            <tr>
            <label>Set Output Path:</label></tr>
             <tr><div id='fileList'><input type="text" placeholder='Set Output Path'/></div>
             </tr>
            <tr>
            <label>Select Data Source:</label></tr>
            <tr>
            <Form.Select className='SelectOption' size="lg">
            <option>Select Data Source</option>
            <option>Source 2</option>
            <option>Source 3</option>
          </Form.Select></tr>
            <tr>
            <label>Enter Company Name(Optional):</label></tr>
            <tr>
            <input type="text" placeholder='Enter Company Name'/></tr>
            <tr>
            <label>Enter HS Code(Optional):</label></tr>
            <tr>
            <input type="text" placeholder='Enter Company Name'/></tr>
          </div>
          <div>
          <div>
            <input type="file" style={{color:"transparent"}} onChange={updateList} id="selectFile" />
          </div>
          </div>
          </div>
          <button className='btn-2' type='submit'>Submit</button>
        </form>
      </div>
    </>
     );
export default DataExtractor;

And this is my server side code

const express = require('express');
const fileUpload = require('express-fileupload');
const app = express();
app.use(fileUpload());
//upload Endpoint
app.post('/upload', (req, res)=>{
    if(req.files === null){
        return res.status(400).json({msg:'No file uploaded'})
    }
    const file = req.files.file;    file.mv('${__dirname}/client/public/uploads/${file.name}', err =>{
       if(err){
        console.error(err);
        return res.status(500).send(err)
       }
       res.json({fileName: file.name, filePath:'/uploads/${file.name}'})
    })
}); 
app.listen(5000, () => console.log('Server Started...'));

Add indicators to carousel bootstrap and hide text option

Hello i have a landing page where is carousel with information about team. I would like to add pagination to this carousel. When i add controls to this carousel they are not showing.
Also i want to change my javascript function wchich is showing more text when its too long. I would like to add option to hide it, because right now its only option to show text. I need option to also hide it. Thanks for help.

<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>

carousel:

  <div class="container my-2" style="padding-top: 3em">
      <h1 class="text-center h1 me-2">Title 2</h1>
      <div class="row d-flex justify-content-center">
        <div class="col-12">
          <div
            id="carousel"
            data-interval="2000"
            class="carousel slide"
            data-ride="carousel"
          >
            <ol class="carousel-indicators">
              <li
                data-target="#carouse1"
                data-slide-to="0"
                class="active bg-dark"
              ></li>
              <li
                data-target="#carouse2"
                data-slide-to="1"
                class="bg-dark"
              ></li>
              <li
                data-target="#carouse3"
                data-slide-to="2"
                class="bg-dark"
              ></li>
            </ol>

            <div class="carousel-inner">
              <div class="carousel-item active" id="karuzel1">
                <div class="row">
                  <div class="col-12 col-md-6 col-xl-3 mb-4">
                    <div class="card mr-3">
                      <img src="logo" class="card-img-top" alt="..." />
                      <div class="card-body">
                        <h5 class="card-title">Title 1</h5>
                        <p class="card-text">
                          <span class="text show-read-more"
                            >Lorem ipsum, dolor sit amet consectetur adipisicing
                            elit. Sint tempore beatae neque porro suscipit
                            repellat unde, minus quisquam architecto voluptatum
                            dolorem ut nisi repellendus voluptates in rerum
                            quam. Ullam, est?Lorem ipsum dolor sit amet
                            consectetur adipisicing elit. Dolore amet facere
                            ratione dolores quo voluptates vel assumenda odit
                            voluptate, ex eum alias nulla eaque! Ratione beatae
                            tempore dolorum vel eos Lorem ipsum dolor sit, amet
                            consectetur adipisicing elit. Ut deserunt ab quasi
                            corrupti, ipsum nesciunt. Quas cum, accusamus saepe,
                            non exercitationem quis vitae tempore perferendis
                            molestias accusantium debitis sunt blanditiis?
                          </span>
                        </p>
                      </div>
                    </div>
                  </div>
                  <div class="col-12 col-md-6 col-xl-3 mb-4">
                    <div class="card mr-3">
                      <img src="logo" class="card-img-top" alt="..." />
                      <div class="card-body">
                        <h5 class="card-title">Title 1</h5>
                        <p class="card-text">
                          <span class="text show-read-more"
                            >Lorem ipsum, dolor sit amet consectetur adipisicing
                            elit. Sint tempore beatae neque porro suscipit
                            repellat unde, minus quisquam architecto voluptatum
                            dolorem ut nisi repellendus voluptates in rerum
                            quam. Ullam, est?Lorem ipsum dolor sit amet
                            consectetur adipisicing elit. Dolore amet facere
                            ratione dolores quo voluptates vel assumenda odit
                            voluptate, ex eum alias nulla eaque! Ratione beatae
                            tempore dolorum vel eos Lorem ipsum dolor sit, amet
                            consectetur adipisicing elit. Ut deserunt ab quasi
                            corrupti, ipsum nesciunt. Quas cum, accusamus saepe,
                            non exercitationem quis vitae tempore perferendis
                            molestias accusantium debitis sunt blanditiis?
                          </span>
                        </p>
                      </div>
                    </div>
                  </div>
                  <div class="col-12 col-md-6 col-xl-3 mb-4">
                    <div class="card mr-3">
                      <img src="logo" class="card-img-top" alt="..." />
                      <div class="card-body">
                        <h5 class="card-title">Title 1</h5>
                        <p class="card-text">
                          <span class="text show-read-more"
                            >Lorem ipsum, dolor sit amet consectetur adipisicing
                            elit. Sint tempore beatae neque porro suscipit
                            repellat unde, minus quisquam architecto voluptatum
                            dolorem ut nisi repellendus voluptates in rerum
                            quam. Ullam, est?Lorem ipsum dolor sit amet
                            consectetur adipisicing elit. Dolore amet facere
                            ratione dolores quo voluptates vel assumenda odit
                            voluptate, ex eum alias nulla eaque! Ratione beatae
                            tempore dolorum vel eos Lorem ipsum dolor sit, amet
                            consectetur adipisicing elit. Ut deserunt ab quasi
                            corrupti, ipsum nesciunt. Quas cum, accusamus saepe,
                            non exercitationem quis vitae tempore perferendis
                            molestias accusantium debitis sunt blanditiis?
                          </span>
                        </p>
                      </div>
                    </div>
                  </div>

                  <div class="col-12 col-md-6 col-xl-3 mb-4">
                    <div class="card mr-3">
                      <img src="logo" class="card-img-top" alt="..." />
                      <div class="card-body">
                        <h5 class="card-title">Title 1</h5>
                        <p class="card-text">
                          <span class="text show-read-more"
                            >Lorem ipsum, dolor sit amet consectetur adipisicing
                            elit. Sint tempore beatae neque porro suscipit
                            repellat unde, minus quisquam architecto voluptatum
                            dolorem ut nisi repellendus voluptates in rerum
                            quam. Ullam, est?Lorem ipsum dolor sit amet
                            consectetur adipisicing elit. Dolore amet facere
                            ratione dolores quo voluptates vel assumenda odit
                            voluptate, ex eum alias nulla eaque! Ratione beatae
                            tempore dolorum vel eos Lorem ipsum dolor sit, amet
                            consectetur adipisicing elit. Ut deserunt ab quasi
                            corrupti, ipsum nesciunt. Quas cum, accusamus saepe,
                            non exercitationem quis vitae tempore perferendis
                            molestias accusantium debitis sunt blanditiis?
                          </span>
                        </p>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

Javascript function to show more text

  $(document).ready(function(){
    var maxLength = 230;
    $(".show-read-more").each(function(){
        var myStr = $(this).text();
        if($.trim(myStr).length > maxLength){
            var newStr = myStr.substring(0, maxLength);
            var removedStr = myStr.substring(maxLength, $.trim(myStr).length);
            $(this).empty().html(newStr);
            $(this).append(' <a href="javascript:void(0);" class="read-more text-decoration-none">...Show more</a>');
            $(this).append('<span class="more-text">' + removedStr + '</span>');
        }
    });
    $(".read-more").click(function(){
        $(this).siblings(".more-text").contents().unwrap();
        $(this).remove();
    });
});


full page available on https://jsfiddle.net/3jpzv8x4/5/

how to read text file and display in textarea in react js

import React from ‘react’;

const Dashboard = () => {

const handleChange = () => {
let input = document.querySelector(‘input’);
let textarea = document.querySelector(‘textarea’);

input.addEventListener('change', () => {
    let files = input.files;

    if (files.length === 0) return;

    const file = files[0];

    let reader = new FileReader();

    reader.onload = (e) => {
        const file = e.target.result;
        const lines = file.split(/rn|n/);
        console.log(lines);
        textarea.value = lines.join('n');
    };

    reader.onerror = (e) => alert(e.target.error.name);

    reader.readAsText(file);

});   }
return ( <div style={{display: 'flex', }}  >
  
  <input type="file" name="input" onChange={handleChange}/>
  <textarea cols={30} rows={20}  
    style={{marginTop: 15, width:'50%'}} ></textarea>
  
 
  </div>
)

};

export default Dashboard;

Testdome Vue question – working locally but not passing test

I am practicing for a vue TestDome test this week. One of the practice questions is as follows :

An image gallery is a set of images with corresponding remove buttons. This is the HTML code for a gallery with two images:

<div>
  <div class="image">
    <img src="https://www.testdome.com/files/resources/12362/aff5c408-79f8-4220-9769-8b4cde774c98.jpg">
    <button class="remove">X</button>
  </div>
  <div class="image">
    <img src="https://www.testdome.com/files/resources/12362/dbd97d8f-cc11-48bd-bf21-b8762a39a55e.jpg">
    <button class="remove">X</button>
  </div>
</div>

Implement the image-gallery component that accepts a links prop and renders the gallery described above so that the first item in the links prop is the src attribute of the first image in the gallery. It should also implement the following logic: When the button is clicked, the image that is in the same div as the button should be removed from the gallery.

The component should be usable with any root Vue instance.

For example, after the first image has been removed from the gallery above, it’s HTML code should look like this:

<div>
  <div class="image">
    <img src="https://www.testdome.com/files/resources/12362/dbd97d8f-cc11-48bd-bf21-b8762a39a55e.jpg">
    <button class="remove">X</button>
  </div>
</div>

Here is my solution, which when run locally, renders the two images and buttons, as well as deletes them when clicked.

<!DOCTYPE html>
<html>
<head>
  <title>Image Gallery</title>
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.min.js"></script>
</head>
<body>
  <div id="app">
    <image-gallery :links="links" @remove-link="removeLink"/>
  </div>
  <script>
    // Create image-gallery component that accepts link prop
    Vue.component('image-gallery', {
      props: ['links'],
      template: `
      <div>
        <div v-for="link in links" class="image">
          <img :src="link" />
          <button @click="removeLink(link)" class="remove">X</button>
        </div>
        </div>
      `,
      methods: {
        removeLink (link) {
          this.$emit('remove-link', link)
        }
      }}
    );
    
    var vm = new Vue({
      el: "#app",
      data () {
        return {
          links: ['https://www.testdome.com/files/resources/12362/aff5c408-79f8-4220-9769-8b4cde774c98.jpg', 'https://www.testdome.com/files/resources/12362/dbd97d8f-cc11-48bd-bf21-b8762a39a55e.jpg']
        }
      },
      methods: {
        removeLink(link) {
            this.links = this.links.filter(l => l !== link)
        }
      }
      }
    );
    
    // Example case
    let firstButton = document.querySelectorAll("div.image > button")[0];
    if(firstButton) {
    firstButton.click();  
    }
    
    setTimeout(() => console.log(document.getElementById("app").innerHTML));
  </script>
</body>
</html>

The results according to testdome:
Example case: Wrong answer
ImageGallery will render the correct list: Correct answer
Remove a single image: Wrong answer
Remove multiple images: Wrong answer

Run OK, but 3 out of 4 test cases failed.

Output:

<div><div class="image"><img src="https://www.testdome.com/files/resources/12362/dbd97d8f-cc11-48bd-bf21-b8762a39a55e.jpg"> <button class="remove">X</button></div></div>

Unless I am reading the question wrong, the result is correct. What am I missing?

Can someone confirm below array is a valid javascript array?

We mainly write object or string in an array like this –

const arr = [{id: 123}, 'test']

And then we can access it through the index of the item –

console.log(arr[0], arr[1]);

But is it a valid array if we do like this –

const arr = [];
arr['id'] = {message: 'Hello'};
arr['name'] = 'test';

Because it doesn’t giving any error and still i can access the items through –

console.log(arr['id'], arr['name'])

How To Change The PointBackgroundColor Dynamically In ChartJS?

The Source Code:

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>Testing Chart.js Line Chart</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.8.0/chart.min.js" integrity="sha512-sW/w8s4RWTdFFSduOTGtk4isV1+190E/GghVffMA9XczdJ2MDzSzLEubKAs5h0wzgSJOQTRYyaz73L3d6RtJSg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
</head>

<body>
    <button type="button" onclick="add()" id="btnAdd">Add 10</button>
    <button type="button" onclick="subtract()" id="btnSubtract">Subtract 10</button>
    <canvas id="chart_canvas">Your browser does not support the HTML5 canvas tag.</canvas>

    <script type="text/javascript">

    // Set Chart Global Variables
    let x_values = [];
    let y_values = [];
    let new_number = 0;
    let index = 0;
    let chart_canvas = document.getElementById("chart_canvas");

    // Intialize Data
    x_values.push(index);
    y_values.push(index);

    // Create New Chart
    my_chart = new Chart(chart_canvas, {
        type: "line",
        data: {
            labels: [x_values[index]],
            datasets: [{
                backgroundColor: "#d8dee980",
                pointBackgroundColor: "#81a1c1ff",
                fill: true,
                pointStyle: "circle",
                label: "Values",
                data: [y_values[index]]
            }]
        }
    });

    // ------ Local Functions ------

    function add() {
        index = my_chart.data.datasets.length;
        new_number += 10;
        my_chart.data.labels.push(index);
        my_chart.data.datasets.forEach((dataset) => {
            dataset.data.push(new_number);
        });

        // -------
        //The below line is changing all point background colors instead of the last one only!
        my_chart.data.datasets[index - 1].pointBackgroundColor = "#88c0d0ff";
        // -------

        my_chart.update();

    }

    function subtract() {
        index = my_chart.data.datasets.length;
        new_number -= 10;
        my_chart.data.labels.push(index);
        my_chart.data.datasets.forEach((dataset) => {
            dataset.data.push(new_number);
        });

        // -------
        //The below line is changing all point background colors instead of the last one only!
        my_chart.data.datasets[index - 1].pointBackgroundColor = "#bf616aff";
        // -------

        my_chart.update();
    }
    </script>
</body>

</html>

Expected Output / Objective:

  • When the “Add 10” button is clicked, a new point entry needs to be added with a pointBackgroundColor in green.
  • When the “subtract 10” button is clicked, a new point entry needs to be added with a PointBackgroundColor in red.

Current Outcome:

All point background colors are changing together instead of the last one only.

Why my console.log is showing ‘Undefined’ first And Then Display The required number even after i log it after a settimeout of 2 sec {REACT}

I am sending AllmightyUID = 2(for example) from App.js in the User.js component through contextApi ,there is no useEffect in my User component , but when i log the value in my User component it is logged 2 times first time is shows undefined and second time correct data(2) even if i log it after 2- 3 seconds due to this i am unable to make further api calls (i get cannot read the value undefined errors)

solutions i have tried :-
1 i have removed strict mode from index.js
2 passed the value as props but still the same problem

import React, { useContext, useState } from ‘react’
import { AllMightyUID } from ‘../App’
import axios from ‘axios’

const User = (props) => {

let receivedUID = useContext(AllMightyUID)

const [UID1, setUID1] = useState();

setTimeout(() => {

console.log(receivedUID);

}, 2000);

return(
<></>
)
}

i am sending data from a state variable in App.js

how long Express.js will survive against others backend frameworks?

I have been working as a freelance web developer for a long time but now a few questions are just rolling around in my head!

What is the current demand for express.js?

Apart from express, nodejs has many backend frameworks… eg: koa, hapi, adonis, loopback etc… then again deno & bun (for which node’s existence is threatened [I think])!

So will there be demand for node/express in the future among so many competitors?

Note: I work with mern and also have experience with python(flask, django), in this case should I keep express as backend or go with django + react?

In short, express or django which job is more!
Or if you learn which one can survive in the market for the next 5-10 years?

I am very depressed

Angular 11: My owl-date-time-calendar not consuming the click and close ng-popover

Using owl-date-time-calendar inside the ng-popover menu

when use multiple ng-popover menu in one screen, and use popover-trigger="'outsideClick'" & popover-trigger="focus"

when selecting a date from owl-date-time-calendar inside ng-popover, the date picker does not consume the click, and ng-popover close automatically behaves like a click outside of the ng-popover and closing the ng-popover.

Angular : V11.0.4
Boostrap : V4.0.0

A cleaner way to write this block of JS code

I’m following a JS course for beginners and the first lesson was about making a “rock, paper, scissors” game.

The instructor said something about this not being the most efficient way to determine the winner but didn’t really touch on how to write it. All I can think of is using Switch statement instead of if.

Can someone show me how it should be done?

function getResult(){
    if (computerChoice === userChoice) {
        result = "It's a draw";
    } else if (computerChoice == "rock" && userChoice == "scissors") {
        result = 'You lost';
    } else if (computerChoice == "rock" && userChoice == "paper") {
        result = 'You won!';
    } else if (computerChoice == "paper" && userChoice == "scissors") {
        result = 'You won';
    } else if (computerChoice == "paper" && userChoice == "rock") {
        result = 'You lost';
    } else if (computerChoice == "scissors" && userChoice == "rock") {
        result = 'You won';
    } else if (computerChoice == "scissors" && userChoice == "paper") {
        result = 'You lost';
    }
    resultDisplay.innerHTML=result;
}

Thanks,
Amin