res.append Method in Express.js

Mayank Agarwal
Updated on 29-Jan-2022 07:22:30

1K+ Views

The res.append() method can append a specified value to the HTTP response header field. It creates new headers with the specified values, if it's not already created. The value string can take both a string input or an array.Syntaxres.append( field, [value] )Example 1Create a file with the name "resAppend.js" and copy the following code snippet. After creating the file, use the command "node resAppend.js" to run this code as shown in the example below −// res.append(field, [value]) Method Demo Example // Importing the express module var express = require('express'); // Initializing the express and port number var app ... Read More

RES App Property in Express.js

Mayank Agarwal
Updated on 29-Jan-2022 07:17:58

292 Views

The res.app property holds a reference to the instance of an Express Application that is being used by the middleware.Syntaxres.appExample 1Create a file with the name "resApp.js" and copy the following code snippet. After creating the file, use the command "node resApp.js" to run this code as shown in the example below −// res.app code Demo Example // Importing the express module var express = require('express'); // Initializing the express and port number var app = express(); var PORT = 3000; // Creating an endpoint app.get('/', function (req, res) { console.log(res.app.get('views')); ... Read More

req.path Property in Express.js

Mayank Agarwal
Updated on 29-Jan-2022 07:15:56

2K+ Views

The req.path property contains the path part of the requested URL. This property is widely used to track the incoming requests and their paths. It is mainly used for logging the requests.Syntaxreq.pathExample 1Create a file with the name "reqPath.js" and copy the following code snippet. After creating the file, use the command "node reqPath.js" to run this code as shown in the example below −// req.path Property Demo Example // Importing the express & cookieParser module var cookieParser = require('cookie-parser'); var express = require('express'); // Initializing the express and port number var app = express(); // Initializing ... Read More

App Enabled Method in Express.js

Mayank Agarwal
Updated on 29-Jan-2022 07:11:22

234 Views

The app.enabled() method checks whether a setting name property is enabled or not. It basically checks the value of a setting name and returns True if the property value is also True.Syntaxapp.enabled( name )Example 1Create a file with the name "appEnabled.js" and copy the following code snippet. After creating the file, use the command "node appEnabled.js" to run this code as shown in the example below −// app.enabled() Method Demo Example // Importing the express module const express = require('express'); // Initializing the express and port number var app = express(); // Initializing the router from express ... Read More

Final Value Theorem of Z-Transform

Manish Kumar Saini
Updated on 29-Jan-2022 06:12:21

23K+ Views

Z-TransformThe Z-transform is a mathematical tool which is used to convert the difference equations in discrete time domain into the algebraic equations in z-domain. Mathematically, if $\mathit{x}\mathrm{\left(\mathit{n}\right)}$ is a discrete time function, then its Z-transform is defined as, $$\mathrm{\mathit{Z}\mathrm{\left[\mathit{x}\mathrm{\left(\mathit{n}\right)}\right]}\:\mathrm{=}\:\mathit{X}\mathrm{\left(\mathit{z}\right)}\:\mathrm{=}\:\sum_{\mathit{n=-\infty}}^{\infty}\mathit{x}\mathrm{\left(\mathit{n}\right)}\mathit{z^{-\mathit{n}}}}$$Final Value Theorem of Z-TransformThe final value theorem of Z-transform enables us to calculate the steady state value of a sequence $\mathit{x}\mathrm{\left(\mathit{n}\right)}$, i.e., $\mathit{x}\mathrm{\left(\mathit{\infty}\right)}$ directly from its Z-transform, without the need for finding its inverse Z-transform.Statement - If $\mathit{x}\mathrm{\left(\mathit{n}\right)}$ is a causal sequence, then the final value theorem of Z-transform states that if, $$\mathrm{\mathit{x}\mathrm{\left(\mathit{n}\right)}\overset{\mathit{ZT}}{\leftrightarrow}\mathit{X}\mathrm{\left(\mathit{z}\right)}}$$And if the Z-transform X(z) has no poles outside ... Read More

Find the Largest Twins in Given Range in C++

sudhir sharma
Updated on 28-Jan-2022 11:43:13

217 Views

In this problem, we are given two values lValue and hValue. Our task is to find the largest twins in given range.Two numbers are said to be twin numbers if both of them are prime numbers and the difference between them is 2.Let's take an example to understand the problem, Input : lValue = 65, rValue = 100 Output : 71, 73Solution ApproachA simple solution to the problem is by looping from rValue - 2 to lValue and checking each pair of i and (i+2) for twins and print the first occurred twin.Another Approach is by finding all prime numbers ... Read More

Find Largest Pair Sum in Unsorted Array in C++

sudhir sharma
Updated on 28-Jan-2022 11:32:16

1K+ Views

In this problem, we are given an arr[] consisting of N unsorted elements. Our task is to find the largest pair sum in an unsorted array.We will find a pair whose sum is the maximum.Let's take an example to understand the problem, Input : arr[] = {7, 3, 9, 12, 1} Output : 21Explanation −Pair with largest sum, (9, 12). Sum = 21 Solution ApproachA simple solution to the problem is by making a pair of maximum and second maximum elements of the array.For this we will initialise the max and secondMax elements of the array with the first and ... Read More

Find the Largest Number with N Set and M Unset Bits in C++

sudhir sharma
Updated on 28-Jan-2022 11:28:26

186 Views

In this problem, we are given two integer values, n and m. Our task is to find the largest number with n set and m unset bits in the binary representation of the number.Let's take an example to understand the problemInput : n = 3, m = 1 Output : 14Explanation −Largest number will have 3 set bits and then 1 unset bit. (1110)2 = 14Solution ApproachA simple solution to the problem is by finding the number consisting of (n+m) set bits. From this number, toggle off the m bits from the end (LSB). To create a number with (n+m) ... Read More

Find Largest Number with Given Digits and Sum in C++

sudhir sharma
Updated on 28-Jan-2022 11:21:10

2K+ Views

In this problem, we are given two integer values, N denoting the count of digits of a number and sum denoting the sum of digits of the number. Our task is to find the largest number with given number of digits and sum of digits.Let's take an example to understand the problem, Input : N = 3, sum = 15 Output : 960Solution ApproachA simple approach to solve the problem is by traversing all N digit numbers from the largest to smallest. The find the digit sum numbers, if it's equal to sum return the number.ExampleProgram to illustrate the working ... Read More

Find the Largest Node in Doubly Linked List in C++

sudhir sharma
Updated on 28-Jan-2022 11:13:04

359 Views

In this problem, we are given a doubly linked list LL. Our task is to find the largest node in Doubly Linked List.Let's take an example to understand the problem, Input : linked-list = 5 -> 2 -> 9 -> 8 -> 1 -> 3 Output : 9Solution ApproachA simple approach to solve the problem is by traversing the linked-list and if the data value of max is greater than maxVal's data. After traversing the linked-list, we will return the macVal nodes data.ExampleProgram to illustrate the working of our solution#include using namespace std; struct Node{    int data;   ... Read More

Advertisements