Posts

Showing posts from November, 2022

What is MERN?

1. Introduction MERN stands for MongoDB, Express, React, and Node. 2. Big Picture for the MERN Architecture Client (Browser) : ReactJS : Responsible for presentation and the user interface. NodeJS & Express : Server-side responsible for business logic and file storage. The server side and client side communicate with requests and responses in JSON format. Database : MongoDB : Responsible for persistent data storage. NodeJS & Express communicate with MongoDB through database queries using the MongoDB SDK. 3. Diving into Client Side React single-page application is served from the server to the browser. React handles rendering everything in the browser. React manages frontend or client-side routing with an extra library, react-router-dom . react-router-dom helps render different React components based on the path the user enters into the URL bar of the browser. The React application typically handles some front-end state that influences what is shown on t

Javascript Currying

Transform a function with multiple parameters into calling a nesting function multiple times with one parameter; the functionality of the two situations is not changed. For example, the following functions have the same functionality but different formats: // original format function add(a, b) { return a + b; } // currying format function curryingAddFirst(a) { return function (b) { return a + b; }; } // currying format with arrow function const curryingAddSecond = (a) => (b) => a + b;

Smart contract

A smart contract is a computer program or a transaction protocol that is intended to automatically execute, control or document events and actions according to the terms of a contract or an agreement. This is a smart contract: // SPDX-License-Identifier: MIT pragma solidity ^0.8.13; contract Counter { uint public count; // Function to get the current count function get() public view returns (uint) { return count; } // Function to increment count by 1 function inc() public { count += 1; } // Function to decrement count by 1 function dec() public { // This function will fail if count = 0 count -= 1; } }