1. Find the largest element in an array
var arr = [10, 20, 30, 40, 50];var max = arr[0];for(var i=0; i < arr.length; i++) {  var a = arr[i];  if(a > max){    max = a;  }}console.log(“Largest in the array: “, max);

2. Sum of all the elements in an array

var arr = [10, 20, 30, 40, 50];var sum = 0;for(var i=0; i < arr.length; i++) {  var a = arr[i];  sum += a;}console.log(“Sum of the elements in the array: “, sum);

3. Remove duplicate items from an array

var arr = [10…

The common misconception is that React is framework but it is not. React is a popular JS library to build UI.

Let’s deep into the dive with React.

  1. Create React App

To create react app
npx create-react-app react-app
command is required. And it will start the process of creating single page web application.

2. Directory view and Run the app
After creation of react app it will create a directory with the app name in the current directory.

├── README.md
├── node_modules
├── package.json
├── .gitignore
├── public
│ ├── favicon.ico
│ ├── index.html
│ └── manifest.json
└── src
├── App.css
├── App.js
├── App.test.js
├── index.css

1. JavaScript try/catch/finally Statement

While writing codes it is very common that error happens and to handle these errors JS have 4 statements. These are try, catch, throw and finally.


try {
Lines of code
catch(err) {
Lines of code to check errors
finally {
Lines of code which must be executed after try and catch


<!DOCTYPE html>
<html lang=”en”>
<meta charset=”UTF-8">
<meta name=”viewport” content=”width=device-width, initial-scale=1.0">
<title>Error Handling</title>
<h3>Error Handling in JS</h3>
<p id=”errorMessage”></p>
<p id=”finally”></p>

<script type = “text/javascript”>
const result = Multiplication(10, 20); // Multiplication is not defined

JavaScript String Methods
  1. charAt()
    Suppose, you want to return the character at a specified index in a string then you may use the charAt() method. Where 0 is the index of the first character, 1 is the index of the second character, and so on.




var sampleString = “New String”;
var requiredCharacter = sampleString.charAt(0);

If you to return the last character of the string then

var sampleString = “New String”;
var lastCharacter = sampleString.charAt(sampleString.length-1);

2. concat()
Sometimes you do not need to change the existing strings, but return a new string combining two or more strings then you may…


B.Sc. in Computer Science and Engineering. University of Barishal, Barishal.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store