Javascript Dictionaries – Reducing and combining?

Currently working on a relatively simply project.

Let’s say I have a dictionary as follows:

{
Catco: 230,
DogsRUs: 100,
ChickenLickin_US: 100,
ChickenLickin_APAC: 200,
ChickenLicken_EMEA: 100,
Foxtrot_1: 23,
Foxtrot_34: 34
}

I’m looking to reduce and combine entries that are similar, but seperated by a very fine line. This dictionary is subject to change, but principly I’d like to productionize it so it can run fine and merge what needs to be merged.

    {
Catco: 230,
DogsRUs: 100,
ChickenLickin: 400,
Foxtrot: 57
}

I’ve looked into reduce and regex, but I figured I’d touch here for some starting notes. Thanks a lot!

How to get access to react app protected by keycloak without login step?

I have a sample react application using keycloak on a dev stand to get access.
There is a HOC – <ReactKeycloakProvider> on the top level from @react-keycloak/web

I am trying to make it autonomous and proxy all requests to my endpoint (not dev stand).

But don’t know how to login without a server with keycloak.
Are there any way to implement it without creating all openId flow with Authorization Code, ID Token and Access Token

JQuery how to do AJAX call when checkbox is clicked and send its state?

I want to make an AJAX call when the user clicks on a checkbox. The call sends an id along with the checkbox state. Right now when I click my checkbox it creates two AJAX calls, one with the first id in the list and one is correct one I clicked.

How can I send one ajax call of the checkbox I clicked?

HTML:

   <tr class="test-row" data-customerid="1000">
 <td data-content="Customer ID" class="" style="max-width:700px">1000</td>
 <td class="toggle-checkbox" data-content="">
   <div class="custom-control custom-switch no-click">
     <input type="checkbox" checked="checked" class="custom-control-input toggle-checkbox" id="">
     <label class="custom-control-label" for="">&nbsp;</label>
   </div>
 </td>

I have hundreds of rows with customer id 1000, 1001, 1002 etc.
Right now the AJAX call is always 1000 and an ajax call with the customer id I clicked.
Lets say I click the checkbox on row with customer id 1005 then the AJAX call right now is:

testurl&cid=1000&checkbox=1
testurl&cid=1005&checkbox=1

JQuery:

$document.on('change', '.toggle-checkbox', function () {
    var $this = $(this);
    var customerid= $row.data('customerid');
    var checkState = '';

 if($(this).is(':checked')) {
     checkState = 1;
 }
 else {
     checkState = 0;
 }



$.ajax({
    url: base_url + "testurl",
    type: "GET",
    data: {cid: customerid, checkbox: checkState},
    success: function (result) {
        console.log('succesful change');
    },
    error: function (xhr, status, error) {
        console.log('unsuccesful change');
    }
});

});

❝Help❞.micro+soft.com 🗽‍ +1877✔️947✔️7788 🗽🗽‍ 【❝❝Talk❞❞】 to a Person USA

Help.microsoft.com +1-877-947-7788 rebuilds the data utility but doesn’t fix the help.microsoft.com talk to a person. This is often a complicated issue and has required fixing as soon as possible. When this Help.microsoft.com occurs users generally get the message, ‘Recover data file’ or ‘Your help.microsoft.com isn’t working. For this help.microsoft.com talk to a person, the help.microsoft.com file must fix and recovered. To stop this Help.microsoft.com from doing any damage, restore a backup copy, and then condense the company file. It’s a really support software issue that needs immediate help.microsoft.com mention and will be fixed as soon as possible. How does help.microsoft.com +1-877-947-7788 talk to a person affect? As mentioned earlier they skipped 111 Help.microsoft.com is one of the most accounting. help.microsoft.com s in MS OFFICE. So it means the business or user is at constant risk of Contact of help.microsoft.com This help.microsoft.com talk to a person mostly occurs within the application system because of file damage. The file must be repaired by either restoration or by replacing it with an earlier saved backup copy of the stored data. help.microsoft.com talk to a person- However, this is often help.microsoft.com talk to a person software within the end and that’s why help.microsoft.com talk to a person sometimes it does face issues affecting the business operations of its users. An issue that’s quite common has the help.microsoft.com +1-877-947-7788. This Help.microsoft.com code recovers the data that has been founded and again rebuilds the data section. losing their financial and operational data. Then they need storing in MS OFFICE. It’s imperative to make a backup of the data to stop problems in the future. Steps to resolve help.microsoft.com talk to a person Wherever there’s a problem there’s always a resolution. A similar is that the case with help.microsoft.com talk to a person +1-877-947-7788. Below mentioned are some steps that may help to repair can pass few tests and if your file passes these tests, then the backup of the file has automatically been created in the ADR folder. After this, the logging program of ADR transactions will invoice all the transactions quickly also as automatically. It’ll invoice all the transactions that have integrated with the file from a specific instance on help.microsoft.com talk to a person +1-877-947-7788 Software. Once the recovering process is complete, help.microsoft.com accounting software will create a duplicate of that file. But if your application is open, you’d not find any backup created. This may produce two backup duplicates and also the latest one would be 12 hours old while another would be 24 hours old. This way the oldest file would get deleted.

react-native-searchable-dropdown is not working on IOS but working fine on android in react native

I have added react-native-searchable-dropdown in my app which is working fine on android but on IOS it’s not working. I am not able to click on it or nothing pops up like keyboard. Also, I can’t see any errors.

On android simulator, everything is working fine.

 <SearchableDropdown
                            onTextChange={async (text) => {
                              console.log("text is", text);
                              await this.loadSearchData(text);
                              if (text) {
                                this.setState({
                                  search: true,
                                });
                              } else {
                                this.setState({
                                  search: false,
                                });
                              }
                            }}
                            check={(text) => {
                              if (text == true && !this.state.search) {
                                this.setState({
                                  search: true,
                                });
                              }
                            }}
                            //On text change listner on the searchable input
                            onItemSelect={(item) => {
                              console.log("selected", item.name);
                              let skills = this.state.skills;
                              if (!skills.find((skill) => skill == item.name)) {
                                skills.push(item.name);
                              }
                              console.log("Selected skills are", skills);
                              this.setState({
                                skills: skills,
                              });
                            }}
                            //onItemSelect called after the selection from the dropdown
                            containerStyle={{ padding: 0 }}
                            //suggestion container style
                            textInputStyle={{
                              //inserted text style

                              width: wp("82%"),
                              padding: 8,
                              // marginTop: hp('1.67%'),

                              borderColor: this.state.search ? "#fff" : "#fff",
                              backgroundColor: this.state.search
                                ? "#fff"
                                : "#fff",
                              borderRadius: 6,
                            }}
                            itemStyle={{
                              //single dropdown item style

                              padding: 10,
                              //marginTop: 2,
                              backgroundColor: this.state.search
                                ? "#fff"
                                : "#FAF9F8",
                              // borderColor: '#bbb',
                              // borderWidth: 1,
                              width: "100%",
                            }}
                            itemTextStyle={{
                              //single dropdown item's text style
                              color: "#222",
                            }}
                            itemsContainerStyle={{
                              //items container style you can pass maxHeight
                              //to restrict the items dropdown hieght
                              opacity: 1,
                              zIndex: 999,
                              position: "absolute",
                              width: wp("91.7%"),
                              marginTop: hp("7%"),
                              //height: 100,
                              // maxHeight: '60%',
                              borderRadius: 6,
                              borderWidth: 1,
                              borderColor: "#BFBEBE",
                              backgroundColor: "white",
                            }}
                            listProps={{
                              nestedScrollEnabled: true,
                            }}
                            items={this.state.skillData}
                            //mapping of item array

                            //default selected item index
                            placeholder={"e.g., Node.js, Python, React..."}
                            placeholderTextColor={"#BFBEBE"}
                            //place holder for the search input
                            resetValue={false}
                            //reset textInput Value with true and false state
                            underlineColorAndroid="transparent"
                            //To remove the underline from the android input
                          />

I don’t know why it is not working on my ios simulator. How can I solve this issue?

How to Count Number of Data in MongoDB and Display to EJS

I get an output when I’m displaying it through console log, but when I try to display it through ejs I get no output. Is there any way I can display my .countDocument() result through ejs?

Here’s my code:

const getDocument = async() => {
try{
    const result = await Contact
    //to count only the services 
    .find({$or: [{subject:"Land Surveying"} , {subject:"Construction"} , {subject:"Consultation and Planning"} , {subject: "Architecture"}]})
    .countDocuments();
    console.log(result);
}catch(err){
    console.log(err);
}

}
getDocument();

Grid footer covers site content

I have the following code which contains a modification of CSS code suggested by another user in one of my posted questions.

The code implements a grid which is used as a responsive footer menu, which also contains a copyright reference for the site.

The problem is that the footer covers the content of the website. Is there a way to avoid covering any of the 3 tags of the website with the tag that implements the grid?

function myFunction() {
  var x = document.getElementById("myNavbar");
  if (x.className === "navbar") {
    x.className += " responsive";
  } else {
    x.className = "navbar";
  }
}
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
}

#content {
  max-width: 720px;
  margin: 100px auto 0;
}

#divleft {
  position: fixed;
  top: 50%;
  transform: translate(-50%, -50%);
  left: calc((100% - 720px)/4);
  width: 200px;
  height: 400px;
  border: solid;
  border-color: red;
}

#divright {
  position: fixed;
  top: 50%;
  transform: translate(50%, -50%);
  right: calc((100% - 720px)/4);
  width: 200px;
  height: 400px;
  border: solid;
  border-color: red;
}


/*
  The Navigation Container/Block
  */

.navbar {
  background-color: #333;
  position: fixed;
  bottom: 0%;
  right: 0%;
  width: 100%;
}


/*
  Grid Container
  */

.grid-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}


/*
  Item 1
  */

.item-1 {
  text-align: end;
}


/*
  Item 2
  */

.item-2 {
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}


/*
  Item 3
  */

.item-3 {
  text-align: end;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.item-3 a {
  color: #f2f2f2;
  text-align: center;
  padding: 15px 16px;
  text-decoration: none;
}

.item-3 a:hover {
  background-color: #ddd;
  color: black;
}

.item-3 a.active {
  background-color: #04aa6d;
  color: white;
}


/*
  Toggle Icon For Menu
  */

.navbar .icon {
  display: none;
}


/*
  This Will Display In Media Queries
  */

.copyright-bottom {
  display: none;
}


/*
  Media Queries
  */

@media screen and (max-width: 970px) {
  .item-3 a {
    display: none;
  }
  .navbar a.icon {
    display: block;
  }
  .navbar.responsive .icon {
    position: absolute;
    right: 0;
    bottom: 0;
  }
  .navbar.responsive a {
    display: block;
    text-align: left;
  }
  .navbar.responsive .copyright-bottom {
    display: block;
    text-align: center;
    color: white;
  }
  .navbar.responsive .copyright {
    display: none;
  }
  .navbar.responsive .item-3 {
    grid-column: span 3;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
  }
}
<!DOCTYPE html>
<html>

<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
</head>

<body>

  <section id="divleft"></section>

  <section id="content">
    <h2>Responsive Bottom Navbar Example</h2>
    <p>Resize the browser window to see how it works.</p>

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque et viverra justo. Suspendisse quis ligula ac nibh ultricies ultrices. Etiam vel sagittis nunc. Praesent mi justo, ultrices sit amet lectus id, tincidunt volutpat nulla. Vivamus neque dolor,
    elementum sit amet enim in, fringilla faucibus neque. Fusce a lectus enim. Pellentesque risus orci, efficitur et facilisis et, egestas eu eros. Sed commodo lacinia dolor eget suscipit. Ut facilisis orci lorem, et vehicula risus sollicitudin eu. Donec
    aliquam urna at mi consectetur, sed condimentum velit vehicula. Nam et urna fringilla, vulputate risus ac, posuere ante. Morbi at ex et libero lobortis viverra. Donec nibh massa, faucibus a hendrerit ac, faucibus ac diam. Nunc vel gravida dui, euismod
    viverra ex. Praesent elementum egestas venenatis. Duis quis nulla mi. Aliquam efficitur enim ipsum, sed venenatis tortor tempor eu. Maecenas maximus diam nec ante pellentesque, a efficitur ipsum semper. Donec sagittis enim quis nisl efficitur sodales.
    Etiam porttitor tristique urna ut auctor. Mauris eget urna quis diam interdum euismod et vel turpis. Quisque vel tincidunt purus. Aliquam a mauris tortor. Vestibulum fringilla augue sit amet egestas tempus. Pellentesque pellentesque erat id porta
    interdum. Vestibulum eros nibh, sagittis sit amet velit ut, auctor tincidunt tortor. Cras blandit condimentum enim ac sagittis. Nunc pretium, metus id pulvinar efficitur, nunc nunc sagittis sem, eget efficitur elit dui quis nisi. Mauris eros ex, elementum
    sit amet neque at, elementum bibendum quam. Quisque ornare in lacus non maximus. Nullam volutpat, nisi vel consectetur mattis, magna ligula condimentum mauris, sed accumsan nibh augue quis dolor. Aenean id dignissim purus. Donec venenatis condimentum
    nisl, quis placerat lorem suscipit nec. Vestibulum ante massa, euismod et pellentesque ut, eleifend volutpat arcu. Mauris porttitor nec orci vitae hendrerit. Suspendisse cursus urna id ullamcorper placerat. Nullam varius diam ut nibh molestie, a sodales
    leo ultricies. Ut eget felis malesuada, imperdiet lectus finibus, aliquam quam. Pellentesque ac leo aliquam, viverra lorem in, dignissim nisl. Cras ligula mauris, bibendum vel ex ac, sodales ullamcorper magna. Etiam ac libero ut mi semper dignissim.
    Proin eu enim at nunc porttitor mattis. Duis nec nisi vel est lacinia tincidunt. Sed interdum turpis sed ante maximus tristique. Etiam non urna placerat, ornare diam at, dictum massa. Praesent et imperdiet sem, quis varius mauris. Proin nunc elit,
    vehicula non posuere sed, rhoncus vitae nunc. Duis ornare condimentum felis ut tempor. Donec tempor est nec diam gravida fermentum. Sed sit amet libero non tortor ultricies lacinia eu cursus metus. Morbi porta blandit libero sit amet laoreet. Vivamus
    auctor dui sit amet turpis rutrum dapibus. Quisque tortor ipsum, interdum id sodales in, cursus at turpis. Duis dui sapien, finibus vel venenatis a, gravida nec sapien. Aenean tortor lorem, venenatis eu quam ac, ullamcorper pulvinar erat. In hac habitasse
    platea dictumst. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Phasellus eleifend interdum mattis. Praesent et mi nec lacus mattis dictum quis et augue. Donec aliquam rutrum felis ac vestibulum. Sed vehicula
    luctus enim. Vivamus pharetra neque nec ante tincidunt, quis lobortis quam rutrum. Nulla non consequat mauris, vel posuere nisi. Fusce varius imperdiet libero sit amet mattis. Vivamus ut efficitur velit, quis dapibus nisi. Pellentesque tempus turpis
    nec tortor mollis, in euismod lectus porttitor. Proin dignissim accumsan nisi a sollicitudin. Pellentesque scelerisque ipsum eu risus mollis dapibus. Cras eget ornare odio, ac ultricies urna. Aliquam porttitor nunc leo, eleifend pretium magna congue
    ac. In ut odio et ante tincidunt malesuada vel ac velit. Interdum et malesuada fames ac ante ipsum primis in faucibus. Aenean vestibulum tempus velit, nec maximus quam. Proin pellentesque risus vel enim dictum tincidunt. Curabitur purus turpis, efficitur
    eu velit in, efficitur tincidunt neque. Proin dignissim efficitur nisl sit amet efficitur. Sed dictum tellus eu turpis porta porta. Vestibulum in ipsum urna. Donec finibus sed lacus sed mattis. Fusce lacinia mauris vitae mauris lobortis, ut auctor
    neque posuere. Donec scelerisque mauris in justo cursus varius. Aliquam varius sodales diam vel iaculis. In et malesuada velit, nec pulvinar lacus. Quisque eu auctor tortor. Ut iaculis placerat lacus, quis tempor erat lacinia in. Vivamus tempor purus
    velit, vel mollis enim pellentesque sed. Aenean euismod lobortis ultrices. In volutpat sem vitae iaculis dignissim. Sed auctor, leo lobortis aliquam sodales, tellus tortor mattis dolor, sed iaculis elit purus eu nisi. Donec viverra laoreet ipsum eget
    pulvinar. Sed nisl ipsum, congue id ornare eu, vulputate vitae turpis. Suspendisse feugiat dui at elit placerat eleifend. Morbi quam ligula, eleifend nec elit vel, lacinia vehicula nibh. Maecenas in orci ut odio aliquam sodales a vitae urna. Maecenas
    eget interdum dolor. Integer vel magna mi. Suspendisse at consectetur lectus, sed accumsan erat. Aliquam erat volutpat. Mauris non mauris auctor, fringilla arcu vitae, bibendum justo. Sed pulvinar et magna eget cursus. Etiam quis risus vitae ipsum
    pharetra vulputate. Vestibulum commodo ac nisl sit amet porta. Ut ultrices tristique ipsum et commodo. Integer urna ipsum, vehicula convallis metus suscipit, euismod rhoncus lectus. Mauris elementum odio ut odio aliquam, ut fringilla tellus facilisis.
    In vitae arcu ut orci pellentesque consequat. Maecenas sit amet sem a sem varius porta ut a risus. Phasellus ac lacus aliquam, mollis felis vel, finibus arcu. Ut sodales nulla odio, sit amet sodales nibh bibendum ac. Sed purus dolor, iaculis et nunc
    sit amet, viverra maximus nisl.
  </section>

  <section id="divright"></section>

  <footer class="navbar" id="myNavbar">
    <div class="grid-container">
      <div class="item-1"></div>
      <div class="item-2">
        <p class="copyright">© domain.com</p>
      </div>
      <div class="item-3">
        <a href="#about">About</a>
        <a href="#contact">Contact</a>
        <a href="#news">News</a>
        <a href="#home" class="active">Home</a>
        <a href="javascript:void(0);" style="font-size: 15px" class="icon" onclick="myFunction()">&#9776;</a
      >
    </div>
  </div>
  <p class="copyright-bottom">© domain.com</p>
</footer>

</body>

</html>

Function finished with status: ‘ok’ but console logs shows Function returned undefined, expected Promise or value

I am trying to send notifications using firebase cloud functions but when I update the field it shows Function returned undefined, expected Promise or value first, and then Function execution took 364 ms, finished with status: ‘ok’.

My code

const functions = require("firebase-functions");
const admin = require("firebase-admin");
admin.initializeApp();
exports.updateOrderStatus = functions.firestore
    .document("Users/{userId}/Info_Notifications/{notificationId}")
    .onUpdate((change, context) => {
      const newValue = change.after.data();
      const notificationFor = newValue.orderFrom;
      let deviceID;
      const db = admin.firestore();
      db.collection("Tokens").doc(notificationFor).get()
          .then((doc) => {
            const user = doc.data();
            deviceID = user.id;
            console.log("Device id", deviceID);
            const payload = {
              token: deviceID,
              notification: {
                title: "Test Notification",
                body: "message",
              },
              data: {
                priority: "high",
                timeToLive: "60 * 60* 24",
              },
            };
            console.log("Device ID Out", deviceID);
            admin.messaging().sendToDevice(payload)
                .then((response) =>{
                  return true;
                })
                .catch((error) =>{
                  return console.log("Error Sending Notifications", error);
                });
            return null;
          }).catch((error)=>{
            return console.log("Error in fetching data", error);
          });
       });

React uncheck input type check on specific condition

I have 3 inputs type check fields

  • input pick man
  • input pick woman
  • input pick special

The user shall only be able to check a man or woman + special.

The user shall not be able to pick man and woman.

If the users pick man first and wants to pick woman afterwards, the man input shall be unchecked and the woman checkbox shall be picked / checked.

Basically I have following conditions:

  • man + special – allowed
  • woman + special – allowed
  • man + woman – not allowed (only one of them can be picked)

How can I implement this?

So far I have done this:


const TargetViewCard = ({ onChangeTraits }: Props) => {
  const { targetGroupData, targetGroupIsLoading, targetGroupIsError } = useTargetGroupData()
  const [selectedTarget, setSelectedTarget] = useState<ITargetItem[]>([])

  const findTarget = (id: string) => targetGroupData.items.find((target: ITargetItem) => target.id === parseInt(id))

  const checked = (item: ITargetItem) => !!selectedTarget?.find(c => c.id === item.id)

  const toggleTarget = (e: ChangeEvent<HTMLInputElement>) => {
    const target = findTarget(e.target.value)

    let sTarget
    if (selectedTarget.includes(target)) {
      sTarget = selectedTarget.filter(selectedTarget => selectedTarget.id !== target.id)
      setSelectedTarget(selectedTarget.filter(selectedTarget => selectedTarget.id !== target.id))
    } else {
      sTarget = [...selectedTarget, target]
      setSelectedTarget([...selectedTarget, target])
    }

    onChangeTraits(sTarget)
  }

render(
    ...
    {targetGroupData.items.map((item: ITargetItem) => (
        <div key={item.name} className="py-4">
            <label htmlFor={`target-item-${item.id}`}>
            <div>
                {item.name}
                <input
                id={`target-item-${item.id}`}
                name={`target-item-${item.id}`}
                type="checkbox"
                className="hidden"
                value={item.id}
                onChange={e => toggleTarget(e)}
                />
            </div>
            </label>
        </div>
    ))}
)

How to display radio and checkbox values in table using javascript?

form.html

<div class="container">
  <br>
<br>
  <h3 class="text-center">Display answers of form fill in inside a table</h3>
  <br>
<br>
  <form>
  <div class="form-group">
    <label>First Name</label>
    <input id="name" class="form-control form-control-sm" />
  </div>

<div class="form-group">
    <label>Age</label>
    <input id="age" class="form-control form-control-sm" />
  </div>
   
   <div class="form-group">
    Gender:<input type="radio" name="male" id="gender" value="male">Male
       
        <input type="radio" name="female" id="gender" value="female">
        <label for="female">Female</label>
  </div>
    
 <div class="form-group">
<label>Language</label>
  <input type="checkbox" id="language" name="malayalam" value="Malayalam">Malayalam
        <input type="checkbox" id="language" name="english" value="English">English
        <input type="checkbox" id="language" name="hindi" value="Hindi">Hindi
 </div>
  <button type="button" id ="display" class="btn btn-sm btn-primary">Display</button>
</form>


<br>
  <br>
<table  class="table border" id= "table" >
<tr>
<th>Name</th>
<th>Gender</th>
<th>Age</th>
<th>Language</th>
</tr>
</table>

<script type="text/javascript" src="form.js"></script>
</div>

form.js****

(function setup() {
“use strict”;

var NameElem = document.getElementById("name");
var genderElem = document.getElementById("gender");
var ageElem = document.getElementById("age");
var languageElem = document.getElementById("language");
var tableElem = document.getElementById("table");
document.getElementById("display").addEventListener("click", function () {
    var newRow = tableElem.insertRow(-1);
    var newCell = newRow.insertCell(0);
    var newText = document.createTextNode(NameElem.value);
    newCell.appendChild(newText);
    newCell = newRow.insertCell(1);
    newText  = document.createTextNode(genderElem.value);
    newCell.appendChild(newText);
    newCell = newRow.insertCell(2);
    newText  = document.createTextNode(ageElem.value);
    newCell.appendChild(newText);
    newCell = newRow.insertCell(3);
    newText  = document.createTextNode(languageElem.value);
    [newCell.appendChild][1](newText);
    NameElem.value = "";
    genderElem.value = "";
    ageElem.value = "";
    languageElem.value = "";
    tableElem.value = "";
});

})();

When i click display button it displays name and age but gender and checkbox is incorrect it displays first value only. I want to display which i select.
radio data and checkbox data should display
I have given image also please check

How to offset matrix values from up to down by row in Javasript?

I have a matrix and a flip_value that goes for the first element, I want to offset or push down the numbers of a selected column.
For example

let matrix = [
    [1, 2, 3, 4],
    [5, 6, 7, 8],
    [9, 10, 11, 12],
    [13, 14, 15, 16],

];

I want to change the matrix-like that:
So in the second (1st row in the program) is pushed down by 1 and the first element changed.

flip_value  = 999
let matrix =  [1, 999, 3, 4],
        [5, 2, 7, 8],
        [9, 6, 11, 12],
        [13, 10, 15, 16],

The new flip value is 14.

Could you also give me a hint on how to do this from down to up?
flip_value = 999
Like that:

let matrix = [
    [1, 6, 3, 4],
    [5, 10, 7, 8],
    [9, 14, 11, 12],
    [13, 999, 15, 16],

];

//In this method the second-row values are pushed down to up by 1 and the last value in second row the last element flipped.
The new flip_value = 2 here

The whole code which is not working

let matrix = [
    [1, 2, 3, 4],
    [5, 6, 7, 8],
    [9, 10, 11, 12],
    [13, 14, 15, 16],

];

let Yindex = 1;
let flip_value = 999;
let size = 4;




let flip_tmp = matrix[size - 1][Yindex];
console.log("fontos");
for (let i = 1; i < size; i++) {
    //  matrix[i][Yindex] = matrix[i-1][Yindex];
    let tmp = matrix[i][Yindex];
    matrix[i][Yindex] = matrix[i - 1][Yindex];
    matrix[i - 1][Yindex] = tmp;

    console.log(matrix[i][Yindex] + "=" + matrix[i - 1][Yindex]);
}


matrix[0][Yindex] = flip_value;
flip_value = flip_tmp;
for (let i = 0; i < size; i++) {
    console.log("n");
    for (let j = 0; j < size; j++) {
        console.log(matrix[i][j] + " ");
    }
}

for (let i = 0; i < size; i++) {
    console.log("n");
    for (let j = 0; j < size; j++) {
        if (j == 1) {
            console.log(i + "" + j + " " + matrix[i][j] + " ");
        }

    }
}

How to validate phone number in react that until user give valid phone number button should disabled

import React,{useState} from "react";
export default function Validate() {
  const [value, setValue] = useState("");
  const [disable, setDisable] = useState(false);
  function handleChange(e) {
    setValue(e.target.value);
    if (e.target.value.length <10)
     {
      setDisable(true);
    }
  }
  return (
    <>
      Phn:<input error={disable} type="number" value={value} onChange={handleChange}/>
      <button disabled={!disable}>click</button> 
    </>
  );
}

in this case initially button is disabled but when i type one number button is enabled but i need untill user give 10 digit phone number button is disabled

How can I save mongoose data? It doesn’t work


var userid 


User.find({ name: "송형준" }).then(result =>{
    result.forEach(result => {
        userid = result._id
    })
});

const create_room = new Room({
    room_name: 'sexy',
    user_list: `${userid}`,
})

create_room.save()

I’ve been trying to run this code.
But it doesn’t work.
I think the ploblem is in the grammar