skip to Main Content

Jquery – Javascript array search and filter

I want to create new array based on keyword. if my search key word is "align-center" result should be ["align-center"] "align" result should be ["align-left", "align-center", "align-right"] "right" result should be ["align-right"] "arrow" result should be ["align-left", "align-right"] const myarray…

VIEW QUESTION

Javascript – assign numbers to Ids

const randId = "comment_" + Math.floor(Math.random() * 1000); const commentButton = document.createElement("section"); commentButton.id = randId; commentButton.className = "comment2"; let IDArray = []; let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]; function addButtonClick() { if (numbers.length >…

VIEW QUESTION

Javascript – Weird behviour when trying to update an array in reactjs

import { useRef, useState } from "react"; import "./styles.css"; export default function App() { const [array, setArray] = useState(["apple", "mango", "strawberry"]); console.log("outside", array, Date.now()); function update(e) { const name = document.getElementById("name").value; const pos = Number(document.getElementById("pos").value); setArray((prev) => { console.log("prev ===>",…

VIEW QUESTION
Back To Top
Search