---
# System prepended metadata

title: Untitled

---

1) find duplicates in an array
---

let arr =  [1,2,3,4,3,8,1,3, 5,6,7]

<!-- [1,3] -->

// let newarr = new Set(arr)
// console.log(...newarr) 

let n= arr.length;

let obj = {};
for(let p=0; p<n; p++){
    if(obj[arr[p]]==undefined){
        obj[arr[p]]=1;
    }else{
        obj[arr[p]]++;
    }
}
console.log(obj)


// let sorted = arr.sort((a,b) => a-b)
// console.log(sorted)
// let count=0
// for(let p=0; p<n; p++){
//     if(sorted[p] ==undefined){
//         count++;
//     }else{
//         continue;

//     }
// }
// console.log(sorted)


 


// for(var k in obj){
//     console.log(k)
// }


---
2) React timer

---


import { useState } from "react";
export default function counter(){

  const [count, setCount] = useState(0);
  function handleClick(){
    for(let p=count; p<count.length; p++){
    setTimeout(() => {
     setCount(count+1)
    }, 3000)

     }
  }

  return(
    

    <div>
      
     <h1>Count : {count}</h1>

     <button onClick={handleClick}>start</button>
     {/* <button onClick={handlePause}>Pause</button> */}
     
    </div>
  )
}