❤1
// #2 declaration of variables
let a = 1 // block scoped variable
var b = 2 // accessible from other blocks{}
const c = 3 // constant variable
// it insures that program will not assign any value to it again
console.log("var1: " + a);
console.log("var2: " + b);
console.log("var3: " + c);
// @JsCode0
let a = 1 // block scoped variable
var b = 2 // accessible from other blocks{}
const c = 3 // constant variable
// it insures that program will not assign any value to it again
console.log("var1: " + a);
console.log("var2: " + b);
console.log("var3: " + c);
// @JsCode0
👍3
// #3 Taking input in node js
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
readline.question("Enter a number: ", (num) => {
console.log("You entered: " + num);
});
// @jsCode0
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
readline.question("Enter a number: ", (num) => {
console.log("You entered: " + num);
});
// @jsCode0
❤1
// #4 Js list (array) for storing many values
// storing 3 values
let jsArr = [2, 4, 6]
// showing first value
console.log( jsArr[0] )
// @jsCode0
// storing 3 values
let jsArr = [2, 4, 6]
// showing first value
console.log( jsArr[0] )
// @jsCode0
❤1
// #5 Js function
// js function which takes any value and shows them
function show(value){
console.log(value)
}
// call show function with hello value
show("Hello")
// @jsCode0
// js function which takes any value and shows them
function show(value){
console.log(value)
}
// call show function with hello value
show("Hello")
// @jsCode0
// #5 Js function
// js function which takes any value and shows them
function show(value){
console.log(value)
}
// call show function with hello value
show("Hello")
// @jsCode0
// js function which takes any value and shows them
function show(value){
console.log(value)
}
// call show function with hello value
show("Hello")
// @jsCode0
// strings declaration in js
let str = "its js strings"
console.log(str)
let str = "its js strings"
console.log(str)
// integer declaration in js
let num = 76
console.log(num)
let num = 76
console.log(num)
// operation in integer in js
let int1 = 50
let int2 = 8
console.log("Given values ", int1, " and ", int2)
console.log("\nSubtraction: ", int1 - int2)
console.log("Addition: ", int1 + int2)
console.log("Multiplication: ", int1 * int2)
console.log("division: ", int1 / int2)
// @jsCode0
let int1 = 50
let int2 = 8
console.log("Given values ", int1, " and ", int2)
console.log("\nSubtraction: ", int1 - int2)
console.log("Addition: ", int1 + int2)
console.log("Multiplication: ", int1 * int2)
console.log("division: ", int1 / int2)
// @jsCode0
// operation in float in js
let num1 = 50.5
let num2 = 8.3
console.log("Given values ", num1, " and ", num2)
console.log("\nSubtraction: ", num1 - num2)
console.log("Addition: ", num1 + num2)
console.log("Multiplication: ", num1 * num2)
console.log("division: ", num1 / num2)
// @jsCode0
let num1 = 50.5
let num2 = 8.3
console.log("Given values ", num1, " and ", num2)
console.log("\nSubtraction: ", num1 - num2)
console.log("Addition: ", num1 + num2)
console.log("Multiplication: ", num1 * num2)
console.log("division: ", num1 / num2)
// @jsCode0
// List means array but with some difference
// Creating a List
let my_list = [];
console.log("Empty list:", my_list);
my_list = [1, 2, 3, 4, 5];
console.log("List with initial values:", my_list);
// Accessing List Elements
let element = my_list[0];
console.log("Element at index 0:", element);
let last_element = my_list[my_list.length - 1];
console.log("Last element:", last_element);
// Modifying List Elements
my_list[2] = 10;
console.log("List after updating element at index 2:", my_list);
// Adding Elements to the List
my_list.push(6);
console.log("List after appending element:", my_list);
my_list.splice(3, 0, 7);
console.log("List after inserting element at index 3:", my_list);
let another_list = [8, 9, 10];
my_list = my_list.concat(another_list);
console.log("List after extending with another list:", my_list);
// Removing Elements from the List
my_list = my_list.filter(item => item !== 4);
console.log("List after removing element 4:", my_list);
let removed_element = my_list.splice(2, 1);
console.log("List after removing element at index 2:", my_list);
console.log("Removed element:", removed_element[0]);
// Clear list
my_list = [];
console.log("List after clearing all elements:", my_list);
another_list = [8, 9, 10, 5, 7, 3, 9];
my_list = my_list.concat(another_list);
console.log("List after extending with another list:", my_list);
// Slicing a List
let sliced_list = my_list.slice(1, 3);
console.log("Sliced list from index 1 to 3 (exclusive):", sliced_list);
// sub_list
let sub_list = my_list.slice(2);
console.log("Sublist from index 2 till the end:", sub_list);
// reversed_list
let reversed_list = my_list.reverse();
console.log("Reversed list:", reversed_list);
// List Iteration
my_list.forEach(element => {
console.log("Element:", element);
});
my_list.forEach((element, index) => {
console.log("Index:", index, "Element:", element);
});
// Code by @Python_Codes_Pro
// buttons by @IOChannel_bot
// Run by @Compiler0bot
// for Group @CodeCompiler_Bot
// Creating a List
let my_list = [];
console.log("Empty list:", my_list);
my_list = [1, 2, 3, 4, 5];
console.log("List with initial values:", my_list);
// Accessing List Elements
let element = my_list[0];
console.log("Element at index 0:", element);
let last_element = my_list[my_list.length - 1];
console.log("Last element:", last_element);
// Modifying List Elements
my_list[2] = 10;
console.log("List after updating element at index 2:", my_list);
// Adding Elements to the List
my_list.push(6);
console.log("List after appending element:", my_list);
my_list.splice(3, 0, 7);
console.log("List after inserting element at index 3:", my_list);
let another_list = [8, 9, 10];
my_list = my_list.concat(another_list);
console.log("List after extending with another list:", my_list);
// Removing Elements from the List
my_list = my_list.filter(item => item !== 4);
console.log("List after removing element 4:", my_list);
let removed_element = my_list.splice(2, 1);
console.log("List after removing element at index 2:", my_list);
console.log("Removed element:", removed_element[0]);
// Clear list
my_list = [];
console.log("List after clearing all elements:", my_list);
another_list = [8, 9, 10, 5, 7, 3, 9];
my_list = my_list.concat(another_list);
console.log("List after extending with another list:", my_list);
// Slicing a List
let sliced_list = my_list.slice(1, 3);
console.log("Sliced list from index 1 to 3 (exclusive):", sliced_list);
// sub_list
let sub_list = my_list.slice(2);
console.log("Sublist from index 2 till the end:", sub_list);
// reversed_list
let reversed_list = my_list.reverse();
console.log("Reversed list:", reversed_list);
// List Iteration
my_list.forEach(element => {
console.log("Element:", element);
});
my_list.forEach((element, index) => {
console.log("Index:", index, "Element:", element);
});
// Code by @Python_Codes_Pro
// buttons by @IOChannel_bot
// Run by @Compiler0bot
// for Group @CodeCompiler_Bot
👍1
Learn about list many methods given above 👆you can run it by run button
List is a type of array in js
List is a type of array in js
let a = require('axios');
let url = "https://example.com";
let e = " excecuted"
a.get(url).then(r => console.log(0+e));
a.get(url).then(r => console.log(1+e));
a.get(url).then(r => console.log(2+e));
a.get(url).then(r => console.log(3+e));
a.get(url).then(r => console.log(4+e));
// this code demonstrates asynchronous programming here any line of code can be excecuted first
let url = "https://example.com";
let e = " excecuted"
a.get(url).then(r => console.log(0+e));
a.get(url).then(r => console.log(1+e));
a.get(url).then(r => console.log(2+e));
a.get(url).then(r => console.log(3+e));
a.get(url).then(r => console.log(4+e));
// this code demonstrates asynchronous programming here any line of code can be excecuted first