ch
Feedback
Javascript Node Js basic to Advance

Javascript Node Js basic to Advance

前往频道在 Telegram
1 176
订阅者
无数据24 小时
-27
-1130
帖子存档
Learn in 55 seconds How to run codes in telegram 👇 https://t.me/logicBots/163

// fetch song Lyrics
require("jsshort")

async function fLyrics (lyrics){ 

require("axios").get('https://song.panditsiddharth.repl.co/lyrics?song=' + lyrics)

.then(response => {
        console.log(response.data);
      })
  }

input("Enter song name in 2-3 words")
.then(song => fLyrics(song))

// Use jsshort lib for input (simpler)
require("jsshort")

async function sum(){
let a = await input("Enter first number: ")
let b = await input("Enter 2nd number: ")

print("Sum of both numbers is:", end= " ")
print(int(a)+int(b))
}

sum()

इस बाॅट में कोड रन करना सीखें। Learn how to run code in this bot. See bot with Full tutorial: https://t.me/logicBots/147 लाभ
इस बाॅट में कोड रन करना सीखेंLearn how to run code in this bot.
See bot with Full tutorial: https://t.me/logicBots/147 लाभ (Advantage): आप किसी को भी रियल टाइम में कोड का आउटपुट दिखा सकते हो, जिससे अगर आपके कोड में कोई गलती है तो वह भी सरलता से एक दूसरे से डिस्कस करके साॅल्व कर सकते हो। See features written in pic ☝️☝️ You can show the output of the code to anyone in real time, so that if there is any mistake in your code, they can easily solve it by discussing with each other. Full tutorial: https://t.me/logicBots/147

// Fetch song lyrics const input = require("input"); const axios = require("axios"); const readline = require('readline'); const rl = readline.createInterface({   input: process.stdin,   output: process.stdout }); rl.question("Enter song name in 2-3 words: ", async (lyrics) => {     axios.get('https://song.panditsiddharth.repl.co/lyrics?song=' + lyrics)       .then(response => {         console.log(response.data);       })       .catch(error => {         console.error("Error fetching lyrics:", error);       });   rl.close(); });

How good this pic ?

// Sin² theta + Cos² theta const theta = Math.PI / 4; // angle in radians const sinTheta = Math.sin(theta); const cosTheta = Math.cos(theta); const result = Math.pow(sinTheta, 2) + Math.pow(cosTheta, 2); console.log(result); // @Jscode0

// Octal to binary conversion with steps function loop(oct){ let bin = "" for(let i = 0; i < oct.length; i++){ let a = parseInt(oct[i], 8).toString(2).padStart(3, '0') console.log( oct[i] + " = " + a); bin += a } return bin } const readline = require('readline'); const rl = readline.createInterface({   input: process.stdin,   output: process.stdout }); rl.question('Enter Octal number: ', (input) => { let oct = "" + input for(let i = 0; i < oct.length; i++){ if(oct[i] > '7' || oct[i] < '0') if(oct[i] != '.') return console.log(oct + " is not a correct octal num") } console.log( "Given octal number: " + oct +"\n"); if(oct.includes(".")){ let ar = oct.split(".") console.log( "Equivalent binary numbers for each octal number: "); console.log( "\nNow After placing each binary in sequence: \n\nOctal " + oct + " in binary is " + loop(ar[0]) + "." + loop(ar[1])); } else { console.log( "Equivalent binary numbers for each octal number: "); console.log( "\nNow After placing each binary in sequence: \n\nOctal " + oct + " in binary is " + loop(oct)); } rl.close(); }) // @JsCode0

╱╱┏╮ ╱╱┃┃ ▉━╯┗━╮ ▉┈┈┈┈┃ ▉╮┈┈┈┃ ╱╰━━━╯ I hope you like it

// Decimal to Hexadecimal conversion with steps shown function hex(ele){ switch(ele){ case 10: ele = "A"; break; case 11: ele = "B"; break; case 12: ele = "C"; break; case 13: ele = "D"; break; case 14: ele = "E"; break; case 15: ele = "F"; break; } return ele; } function frac(frk) {   if (frk === 0) {     return 0;   }     console.log("\nNow multiplying fractional part by 16");     let i = 0;   let hex = "";     while (frk != 0 && i < 7) {     console.log(frk + " x 16   integer " + Math.floor(frk * 16));         frk = frk * 16;     let k = Math.floor(frk);     hex += k;     frk = (frk - k).toFixed(5);     i++;   }     return hex; } function integer(intgr) {   if (intgr < 1) {     return 0;   }   console.log("Now dividing integer part by 16: ");   let temp = "";   let arr1 = [] // let arr2 = [] let i = 0;   while (intgr > 0) { let hx = hex(intgr % 16)     console.log(intgr + "/16    reminder " + hx);     arr1[i++] = hx;     intgr = Math.floor(intgr / 16);   }   const reversedStr = arr1.reverse().join("");   return reversedStr; } const readline = require('readline'); const rl = readline.createInterface({   input: process.stdin,   output: process.stdout }); rl.question('Enter decimal number: ', (input) => {   let dcml = input; let intgr = Math.floor(dcml); let frk = (dcml - intgr).toFixed(6); console.log("Given decimal " + dcml + "\n"); if (frk == 0) {   console.log("\nHexadecimal is " + integer(intgr)); } else {   console.log("First we divide this number into two parts: integer and fractional part.\n" + dcml + " = " + intgr + " + " + frk + "\n");   console.log("\nAfter adding both parts:\nHexadecimal is " + integer(intgr) + (frk != 0 ? ("." + frac(frk)) : "")); } rl.close(); }); // @jscode0

// Decimal to Octal conversion with steps shown function frac(frk) {   if (frk === 0) {     return 0;   }     console.log("\nNow multiplying fractional part by 8");     let i = 0;   let binary = "";     while (frk != 0 && i < 7) {     console.log(frk + " x 8   integer " + Math.floor(frk * 8));         frk = frk * 8;     let k = Math.floor(frk);     binary += k;     frk = (frk - k).toFixed(5);     i++;   }     return binary; } function integer(intgr) {   if (intgr < 1) {     return 0;   }   console.log("Now dividing integer part by 8: ");   let temp = "";     while (intgr > 0) {     console.log(intgr + "/8    reminder " + intgr % 8);     temp += intgr % 8;     intgr = Math.floor(intgr / 8);   }     const reversedStr = temp.split("").reverse().join("");   return reversedStr; } const readline = require('readline'); const rl = readline.createInterface({   input: process.stdin,   output: process.stdout }); rl.question('Enter decimal number: ', (input) => {   let dcml = input; let intgr = Math.floor(dcml); let frk = (dcml - intgr).toFixed(6); console.log("Given decimal " + dcml + "\n"); if (frk == 0) {   console.log("\nOctal is " + integer(intgr)); } else {   console.log("First we divide this number into two parts: integer and fractional part.\n" + dcml + " = " + intgr + " + " + frk + "\n");   console.log("\nAfter adding both parts:\nOctal is " + integer(intgr) + (frk != 0 ? ("." + frac(frk)) : "")); } rl.close(); }); // @jscode0

// Decimal to binary conversion with steps shown function frac(frk) {   if (frk === 0) {     return 0;   }     console.log("\nNow multiplying fractional part by 2");     let i = 0;   let binary = "";     while (frk != 0 && i < 7) {     console.log(frk + " x 2   integer " + Math.floor(frk * 2));         frk = frk * 2;     let k = Math.floor(frk);     binary += k;     frk = (frk - k).toFixed(5);     i++;   }     return binary; } function integer(intgr) {   if (intgr < 1) {     return 0;   }   console.log("Now dividing integer part by 2: ");   let temp = "";     while (intgr > 0) {     console.log(intgr + "/2    reminder " + intgr % 2);     temp += intgr % 2;     intgr = Math.floor(intgr / 2);   }     const reversedStr = temp.split("").reverse().join("");   return reversedStr; } const readline = require('readline'); const rl = readline.createInterface({   input: process.stdin,   output: process.stdout }); rl.question('Enter decimal number: ', (input) => {   let dcml = input; let intgr = Math.floor(dcml); let frk = (dcml - intgr).toFixed(6); console.log("Given decimal " + dcml + "\n"); if (frk == 0) {   console.log("\nBinary is " + integer(intgr)); } else {   console.log("First we divide this number into two parts: integer and fractional part.\n" + dcml + " = " + intgr + " + " + frk + "\n");   console.log("\nAfter adding both parts:\nBinary is " + integer(intgr) + (frk != 0 ? ("." + frac(frk)) : "")); } rl.close(); }); // @jsCode0

// Decimal integer to binary number function integer(intgr) {   if (intgr < 1)     return 0; console.log("Now dividing decimal by 2: ")   let temp = "";   while (intgr > 0) {     console.log(intgr + "/2    reminder " + intgr % 2);     temp += intgr % 2;     intgr = Math.floor(intgr / 2);   }   const reversedStr = temp.split("").reverse().join("");   return reversedStr; } let dcml = 10; let intgr = Math.floor(dcml); console.log("Given decimal " + dcml + "\n"); console.log("\nBinary is " + integer(intgr));

// run it and see its result and shareit const message = String.fromCodePoint(32, 72, 97, 112, 112, 121, 32, 73, 110, 100, 101, 112, 101, 110, 100, 101, 110, 99, 101, 32, 100, 97, 121, 33); console.log('\u{1F1EE}\u{1F1F3}' + message); // @jscode0

// fetch song lyrics let url = "https://song.panditsiddharth.repl.co/lyrics?song=ae+watan" require("axios").get(url) .then((e)=>{console.log(e.data)})

// fetch song link require("axios").get("https://song.panditsiddharth.repl.co/song?song=ae+watan") .then((e)=>{console.log(e.data)})

String functions 1. length: Returns the length of a string. 2. toUpperCase(): Converts a string to uppercase. 3. toLowerCase(): Converts a string to lowercase. 4. indexOf(searchValue, startIndex): Returns the index of the first occurrence of a specified value in a string, starting from the specified index. 5. lastIndexOf(searchValue, startIndex): Returns the index of the last occurrence of a specified value in a string, starting from the specified index. 6. substring(startIndex, endIndex): Extracts a substring from a string, between the specified start and end indexes. 7. slice(startIndex, endIndex): Extracts a section of a string and returns a new string, between the specified start and end indexes. 8. replace(searchValue, replaceValue): Replaces occurrences of specified value with another value in a string. 9. split(separator): Splits a string into an array of substrings based on the specified separator. 10. trim(): Removes whitespace from both ends of a string. 11. startsWith(searchValue, startIndex): Returns true if a string starts with the specified value; otherwise, returns false. 12. endsWith(searchValue, endIndex): Returns true if a string ends with the specified value; otherwise, returns false. 13. charAt(index): Returns the character at the specified index of a string. 14. concat(str1, str2, ...): Concatenates two or more strings and returns a new string. 15. includes(searchValue, startIndex): Returns true if a string contains the specified value; otherwise, returns false. 16. match(regex): Searches a string for a match against a regular expression and returns an array of matches. @jscode0 #share #support

// Curried function function multiply(a) {   return function(b) {     return a * b;   } } // Curried function can be used with partial application const multiplyByTwo = multiply(2); console.log(multiplyByTwo(4)); // Output: 8 // Or it can be invoked with all arguments at once console.log(multiply(3)(5)); // @jscode0

// get lyrics of any song require('axios') .get('https://song.panditsiddharth.repl.co/lyrics?song=ram+siya+ram') .then(r=>console.log(r.data)) // @jsCode0