// genrate substring var str = "helloworld"; for (var i = 0; i < str.length; i++) { for (var j =i+1; j <str.length; j++) { console.log(str.slice(i,j)); } } function checkpalindrome(str) { var str2=str; var reverse=""; for(var i=str2.length; i>=0; i--) { reverse = reverse+str2[i]; if(reverse==str2) { {return true} } else { return false} } } var bam="aba"; var run = checkpalindrome(bam); console.log(run); // multidimentional Arra var item = [ ["a", "B","c"], ["h", "i","g"], ["d", "e","f"], ] console.log(item[0][2]); console.log(item[1][1]); console.log(item[2][1]); // a ie // insert element inside the array in row wise var arr = []; arr.push([1, 2, 3]); arr.push([1, 4, 3]); arr.push ([1, 9, 0]) arr.push([11, 45, 54]); console.log(arr); var tep = []; tep.push("A"); tep.push("B"); tep.push([i, 98, 08]); console.log(tep); var arr2 =[ ["a", "b", "c"], [1, 2, 3], ["m", "n","0"]]; console.log(arr2); // insert a new element inside the array same as upper question var arr1 = []; arr1.push(["a", "b", "c"]); arr1.push([1,2,3]); arr1.push(["m", "n","o"]) console.log(arr1); // Question you are a given a substring a of length N and character k find // all substring of a that will start with k var dot = "good"; for (var i = 0; i < dot.length; i++) { var box =""; for (var j =i; j <dot.length; j++) { box = box + dot[i]; var count= ""; for (var m =i+j; m < dot.length; m++) { if (dot[i]=="g"){ count++; } } } } console.log(count); // new concept var name = [ ["vishal", 28, "male"], ["Annaya", 30, "female"] ] // fetching all element console.log(name[0][0]); console.log(name[0][1]); console.log(name[0][2]); console.log(name[1][0]); console.log(name[1][1]); console.log(name[1][2]); var name1 = [ ["sheelkumar", 28, "male",["Coading", "running"]], ["Annaya", 30, "female", ["reading ", "hardcoder"]] ] // fetching the element console.log(name1[0][3][0]); // it will print string "o" console.log(name1[0][3][0][5]); // inserting ann array inside a array var floor1 = [1,2,3,4]; var floor2 = [4, 5, 6, 7]; var floor3 = [1, 2, 3, 4]; var blankarr = []; blankarr.push(floor1); blankarr.push(floor2); blankarr.push(floor3); console.log(blankarr) console.log(blankarr.length); console.log(blankarr[2].length);
Write, Run & Share NodeJS code online using OneCompiler's NodeJS online compiler for free. It's one of the robust, feature-rich online compilers for NodeJS language,running on the latest LTS version NodeJS 16.14.2. Getting started with the OneCompiler's NodeJS editor is easy and fast. The editor shows sample boilerplate code when you choose language as NodeJS and start coding. You can provide the dependencies in package.json
.
Node.js is a free and open-source server environment. Node.js is very popular in recent times and a large number of companies like Microsoft, Paypal, Uber, Yahoo, General Electric and many others are using Node.js.
Google chrome's javascript engine V8
and is pretty fast.Asynchronous
, event-driven
and works on single-thread model
thus eliminating the dis-advantages of multi-thread model.Express is one of the most popular web application framework in the NodeJS echosystem.
let moment = require('moment');
console.log(moment().format('MMMM Do YYYY, h:mm:ss a'));
const _ = require("lodash");
let colors = ['blue', 'green', 'yellow', 'red'];
let firstElement = _.first(colors);
let lastElement = _.last(colors);
console.log(`First element: ${firstElement}`);
console.log(`Last element: ${lastElement}`);
Following are the libraries supported by OneCompiler's NodeJS compiler.