Skip to main content

Posts

Use of ForEach in Java Script & Node JS - For Each Loop

USE of ForEach in JavaScript  let friends = [ 'Vasu' , 'Mohit' , 'Sunil' , 'Abhishek' ]; // using forEach friends . forEach ( myFunction ); function myFunction ( item ) {     console . log ( item )   } . .. Output Vasu Mohit Sunil Abhishek // For changing in each element  or if you want to something random or same value with each Elecment of array -  Use below code  let friends = [ 'Vasu' , 'Mohit' , 'Sunil' , 'Abhishek' ]; // using forEach friends . forEach ( myFunction ); function myFunction ( item , index , arr ) {       arr [ index ] = 'Hello ' + item ; } console . log ( friends ) .. Output : - [ 'Hello Vasu' , 'Hello Mohit' , 'Hello Sunil' , 'Hello Abhishek' ] FOR vs ForEach both can be used to manipulate Array   const oldArray = [ 'item1' , 'item2' , 'item3' ]; const newArray = []; // using for loop for ( let i = 0 ; i < oldArr...

How to trigger or pop-up on Button click - java script

  < html > // first way to open pop-up < p style = " align-content: center" >   < A style = " align-content: center" HREF = "https://vasubirla.blogspot.com/" onClick = "return popup(this, 'stevie')" > Vasu Birla </ A >< br > </ p > < p align = "center" >   < input type = "button" onclick = " popup ( this , 'about') " value = "CLICK HERE" > </ p > //2nd way to open new window on click < script > function popup ( mylink , windowname ) {   if (! window . focus )     return true ;   var href ;   if ( typeof ( mylink ) == 'string' )     href = mylink ;   else     href = mylink . href ;   window . open ( href , windowname , 'width=400,height=200,scrollbars=yes' );   return false ; } </ script > </ html >

Create/Launch new Product API +Update an Delete Product by Admin, Get Product Details by customer API Nodejs , MongoDB MERN Stack

 //  Create Required following files mentioned in previous post = https://vasubirla.blogspot.com/2023/02/register-new-user-login-user-delete.html  config.env     Server.js  //app.js  /utilsfolder/errorhander.js /utils/jwtToken.js file 3. /utils/sendEmail.js  file //Create Product Model - and import it in ProductController  //ProductModel.js const mongoose = require ( 'mongoose' ); const ProductSchema = new mongoose . Schema ({     name : {         type : String ,         required :[ true , "please enter produt name" ],         trim : true     },     description : {         type : String ,         required :[ true , "please add product description" ]     },     price : {         type : Number ,         required :[ true , "Product Price is requir...

Register new User, Login User, Delete user, Update User Profile , Forgot/Reset password, Change Password - Node Js , MERN Stack Post 101

Project Folder Architecture will look like this (Setup your Node JS in folder) ========install required package using command - npm install packegeName  for example      npm install express  npm install jsonwebtoken  npm install bcryptjs  etc. etc. ================================================================== First create a file  config.env  inwhich we will set various variable with info   PORT = 4000 Database_url = "mongodb://localhost:27017/E-com" JWT_SECRET = KILVISHKJDKFJKDFJKDKDFKJDSKFSDFKJ   JWT_EXPIRE = 5d COOKIE_EXPIRE = 5 SMTP_SERVICE = "gmail" SMTP_MAIL = 'vasubirla@gmail.com' SMTP_PASSWORD = 'mtvrqzmxlaroeizh' //create your own app pass from your google security setting, this is wrong pass First create Server -  Server.js  const app = require ( './app' ); const dotenv = require ( 'dotenv' ); const connectDatabase = require ( './config/database' ) //Uncaught Exception Handling proce...