Posts

Showing posts from March, 2024

week6.1 memo, card-wrapper

   //create a code which random numbers  //rerandring Ugly Way* //This will reRendering  whole body which is not necacery import { useState } from 'react' import './App.css' function App() {   const [count, setCount] = useState(0)   const [title, setTitle] = useState("dhrup")   const updateTitle = () => {     setTitle("my title is " + Math.random()*100);   }   return (     <>       <button onClick={updateTitle}>Update the title</button>       <Header title={title}></Header>       <Header title="hark2">my name is dhurp</Header>     </>   ) }   function Header({title}) {     return <div>       {title}     </div>     } export default App  

easy, medium, hard question Practices

Image
 ------------------------------------------------//Easy problems \\-------------------------------------------------------- //This is an anagram solution* /*      JS01/easy at main · luciferdk/JS01 (github.com) //code in github   Write a function `isAnagram` which takes 2 parameters and returns true/false if those are anagrams or not.   What's Anagram?   - A word, phrase, or name formed by rearranging the letters of another, such as spar, formed from rasp. */ // check this is anagram or not program function isAnagram ( str1 , str2 ) {     // Handle whitespace, casing, and special characters: 1. Whitespace: /\s+/g : This is a regular expression that matches one or more whitespace characters ( \s+ ). .replace() : This method replaces all occurrences of the matched pattern (whitespace in this case) with an empty string ( "" ). 2. Casing: .toLowerCase() : This method converts all characters in the string to lowercase.  ...

week4.4 deep dive in mongo

//  defining schema const UserSchema = new mongoose.Schema({     email: String,     password: String,     purchasedCourses: [{         type: mongoose.Schema.Types.ObjectId,         ref: 'Course'     }] }); const CourseSchema = new mongoose.Schema({     title: String,     price: 5999 }); //insert one document await db.collection('inventory').insertOne({   item: 'canvas',   qty: 100,   tags: ['cotton'],   size: { h: 28, w: 35.5, uom: 'cm' } }); //insert many document await db.collection('inventory').insertMany([   {     item: 'journal',     qty: 25,     tags: ['blank', 'red'],     size: { h: 14, w: 21, uom: 'cm' }   },   {     item: 'mat',     qty: 85,     tags: ['gray'],     size: { h: 27.9, w: 35.5, uom: 'cm' }   },   {     item: 'mousepad',   ...

week4.2 React foundation

befor making fullstack application install these modules npm create vite@latest npm init/ npm install npm install express npm install mongoose npm install zod npm install cors // todo list app using simple html and js <!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <title>Document</title> </head> <body>         <script>             let globalId = 1;             function marAsDone(todoId) {                 const parent = document.getElementById(todoId);                 parent.children[2].innerHTML = "Done!";             }             function createChild(title, description, id) {   ...