This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 1. String.matchAll() | |
* The matchAll() method returns an iterator of all results matching a string against a | |
* regular expression, including capturing groups. | |
* | |
* URL - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/matchAll | |
*/ | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require("http"); | |
const port = 3000; | |
const app = http.createServer((req,res)=>{ | |
res.write("Hello World"); | |
res.end(); | |
}); | |
app.listen(port,()=>{ | |
console.log("Server started at port "+port); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function main() { | |
//Function to fetch user data from the server | |
function getUserData() { | |
return new Promise(function(resolve, reject) { | |
//Set the user data before hand statically in a variable | |
var userData = [{ | |
name: "Sumit Singh", | |
age: 28, | |
email: "sumit@gmail.com", | |
address: "123 Street, 4th Avenue, New York", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function main(input) { | |
var nameOfUsers = []; | |
var visitsTotal = 0; | |
for (var i = 0; i < input.length; i++) { | |
var user = input[i]; | |
visitsTotal = visitsTotal + user.total_visit_count; | |
if (user.total_visit_count > 5) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://jsfiddle.net/mukherjeeronit/9rxwt0n5/ | |
function main(students){ | |
var namesOfStudent = []; | |
for(var i=0; i<students.length; i++){ | |
var student = students[i]; | |
if(student.contact_numbers.length > 1 && student.age < 18){ | |
namesOfStudent.push(student.name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://jsfiddle.net/mukherjeeronit/bs9k6v37/2/ | |
function main(input) { | |
var adultStudentNames = []; | |
for (var i = 0; i < input.length; i++) { | |
var student = input[i]; | |
if (student.age >= 18) { | |
adultStudentNames.push(student.name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://jsfiddle.net/mukherjeeronit/5q2yz0pj/2/ | |
var i = 10; | |
function main(a = 5) { | |
b = 0; | |
for (i = 1; i < a; i++) { | |
var b = b + i; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://jsfiddle.net/mukherjeeronit/906gx2cb/ | |
function findTopper(students = []) { | |
var topper = { | |
percentage: 0 | |
}; | |
for (var i = 0; i < students.length; i++) { | |
var student = students[i]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//JS Fiddle Link:- https://jsfiddle.net/mukherjeeronit/mnhzkj27/ | |
function multiply(a){ | |
return function(b){ | |
return function(c){ | |
return a*b*c; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//JS Fiddle Link:- https://jsfiddle.net/mukherjeeronit/ac1nvp6j/ | |
function sumOfAllEvenNumbers(arr) { | |
var sum = 0; | |
for (var i = 0; i < arr.length; i++) { | |
isEven(arr[i], function(response) { | |
if (response === true) { | |
sum += arr[i]; | |
} |
NewerOlder