Posts

Showing posts from September, 2021

Template, layout and scope

 Templates:- Prewritten line of codes that a developer or programmer can modify according to his/her needs. The use of templates removes repetition saving a lot of time and making it easier for a developer to create a project. Also, templates are blocks of codes which add feature and content to be render on the page. Layout:- Layouts are files that define the structure of the page such as header, footer, navbar, sidebar, etc Concept of scope:- generally there are two types of scope: 1.) Local: which can only be accessed inside the function they are declared in. 2.) Global: This can be accessed throughout the program. Generally, all data types can be local as well as variable: eg: if var, let, const, are declared inside a function they will be local, and if created outside the function they will be global, but if these three are declared in conditional or loop statements the let will behave differently than var, and const. Meaning in conditional and loop statements the let statement...

To do list (Algo)

 Algorithm for to do list: Step: 1: In terminal initialize npm and install express,body-parse, and ejs. 2: in editor incorporate body-parser and express. 3: Bind express to a constant app 4: Using app.set incorporate ejs with express.                           app.set("view engine", "ejs); 5:using app .use incorporate body-parser(now depreceated), so we can use express instead. 6:using app.get define route and has a call back which will hold the data of get.     6a:  inside call back:-             6a1: create a variable for date                6a2: create an object which will contain the date day month and year to be displayed.               6a3:create a variable which will convert the date toLocaleDateString (Date string) 7: using res.render, render the template (list) and i...

To do list (without styling and css)

the html file is written in the file having extension as ejs rather than HTML because it can include embedded javascript logic inside the file itself. html of ejs todo list:- <!DOCTYPE html> <html lang="en" dir="ltr">   <head>     <meta charset="utf-8">     <title>To do List</title>   </head>   <body>     <% if(kindOfDay==="Saturday"||kindOfDay==="Sunday"){ %>     <h1 style="color:Purple"> <%= kindOfDay %> </h1>     <% } else { %>       <h1 style="color:Blue"> <%= kindOfDay %> </h1>     <%  } %>     <ul>     <% for (var i = 0; i<newListItems.length; i++){ %>       <li> <%= newListItems[i] %> </li>     <% } %>       </ul>     <form class="" action="/" method="post"> ...

Ejs template

// After express body-parser and ejs has been installed using node.  const express = require("express"); const bodyParser=require("body-parser"); const app = express(); app.use("view engine" , "ejs"); //Code to be written here app.listen(3000,()=>{ console.log("Server started at port 3000"); })
 Git Commands to use in CLI: Local Repository: 1. Git init: to initialize a git repository 2. Git add: Adds files to the staging area. 3. Git commit: Adds files to the local repository. 4. Git status: This shows the list of untracked files. 5. git log: displays the log of commits 6 git diff: displays the change between committed and changes done to file. 7: Git Checkout: used to roll back changes to committed files. For remote repository: After creating the local repository: 1. git remote add origin ("URL of repository"): used to define the location of the remote repo. 2. git push -u origin master: used to push the files in the local repository to the remote repository. Additional: touch  .gitignore: creates a hidden file of git ignores. Git ignore is used to ignore the files from the final commit.   git clone (filename): is used to clone any open source repository. Branching and merging: git branch (filename): creates a new branch. git branch: displays the number of...