31. Write a JavaScript program to find the largest of three given integers.
function max_of_three(x, y, z)
{
max_val = 0;
if (x > y)
{
max_val = x;
} else
{
max_val = y;
}
if (z > max_val)
{
max_val = z;
}
return max_val;
}
console.log(max_of_three(1,0,1));
console.log(max_of_three(0,-10,-20));
console.log(max_of_three(1000,510,440));
function max_of_three(x, y, z)
{
max_val = 0;
if (x > y)
{
max_val = x;
} else
{
max_val = y;
}
if (z > max_val)
{
max_val = z;
}
return max_val;
}
console.log(max_of_three(1,0,1));
console.log(max_of_three(0,-10,-20));
console.log(max_of_three(1000,510,440));
32. Write a JavaScript program to find a value which is nearest to 100 from two different given integer values.
function near_100(x, y) {
if (x != y)
{
x1 = Math.abs(x - 100);
y1 = Math.abs(y - 100);
if (x1 < y1)
{
return x;
}
if (y1 < x1)
{
return y;
}
return 0;
}
else
return false;
}
console.log(near_100(90, 89));
console.log(near_100(-90, -89));
console.log(near_100(90, 90));
function near_100(x, y) {
if (x != y)
{
x1 = Math.abs(x - 100);
y1 = Math.abs(y - 100);
if (x1 < y1)
{
return x;
}
if (y1 < x1)
{
return y;
}
return 0;
}
else
return false;
}
console.log(near_100(90, 89));
console.log(near_100(-90, -89));
console.log(near_100(90, 90));
33. Write a JavaScript program to check if two numbers are in range 40..60 or in the range 70..100 inclusive.
function numbers_ranges(x, y) {
if ((x >= 40 && x <= 60 && y >= 40 && y <= 60)
||
(x >= 70 && x <= 100 && y >= 70 && y <= 100))
{
return true;
}
else
{
return false;
}
}
console.log(numbers_ranges(44, 56));
console.log(numbers_ranges(70, 95));
console.log(numbers_ranges(50, 89));
function numbers_ranges(x, y) {
if ((x >= 40 && x <= 60 && y >= 40 && y <= 60)
||
(x >= 70 && x <= 100 && y >= 70 && y <= 100))
{
return true;
}
else
{
return false;
}
}
console.log(numbers_ranges(44, 56));
console.log(numbers_ranges(70, 95));
console.log(numbers_ranges(50, 89));
34. Write a JavaScript program to find the larger number from the two given positive integers, the two numbers are in the range 40..60 inclusive.
function max_townums_range(x, y){
if( (x >= 40) && (x <= 60) && (y >= 40 && y <= 60) ){
if(x === y){
return "Numbers are the same";
}else if (x > y){
return x;
}else{
return y;
}
}else{
return "Numbers don't fit in range";
}
}
console.log(max_townums_range(45, 60));
console.log(max_townums_range(25, 60));
console.log(max_townums_range(45, 80));
function max_townums_range(x, y){
if( (x >= 40) && (x <= 60) && (y >= 40 && y <= 60) ){
if(x === y){
return "Numbers are the same";
}else if (x > y){
return x;
}else{
return y;
}
}else{
return "Numbers don't fit in range";
}
}
console.log(max_townums_range(45, 60));
console.log(max_townums_range(25, 60));
console.log(max_townums_range(45, 80));
35. Write a JavaScript program to check a given string contains 2 to 4 numbers of a specified character.
function check_char(str, char)
{
ctr = 0;
for (let i = 0; i < str.length; i++)
{
if (str.charAt(i) == char) {
ctr++;
}
}
return (ctr >= 2 && ctr <= 4);
}
console.log(check_char("Python", "y"));
console.log(check_char("JavaScript", "a"));
console.log(check_char("Console", "o"));
function check_char(str, char)
{
ctr = 0;
for (let i = 0; i < str.length; i++)
{
if (str.charAt(i) == char) {
ctr++;
}
}
return (ctr >= 2 && ctr <= 4);
}
console.log(check_char("Python", "y"));
console.log(check_char("JavaScript", "a"));
console.log(check_char("Console", "o"));
36. Write a JavaScript program to check if the last digit of the three given positive integers is same
function last_digit(x, y, z)
{
if ((x > 0) && y > 0 && z > 0)
{
return (x % 10 == y % 10 && y % 10 == z % 10 && x % 10 == z % 10);
}
else
return false;
}
console.log(last_digit(20, 30, 400));
console.log(last_digit(-20, 30, 400));
console.log(last_digit(20, -30, 400));
console.log(last_digit(20, 30, -400));
function last_digit(x, y, z)
{
if ((x > 0) && y > 0 && z > 0)
{
return (x % 10 == y % 10 && y % 10 == z % 10 && x % 10 == z % 10);
}
else
return false;
}
console.log(last_digit(20, 30, 400));
console.log(last_digit(-20, 30, 400));
console.log(last_digit(20, -30, 400));
console.log(last_digit(20, 30, -400));
37. Write a JavaScript program to create a new string with first 3 characters are in lower case from a given string. If the string length is less than 3 convert all the characters in upper case.
function upper_lower(str) {
if (str.length < 3) {
return str.toUpperCase();
}
front_part = (str.substring(0, 3)).toLowerCase();
back_part = str.substring(3, str.length);
return front_part + back_part;
}
console.log(upper_lower("Python"));
console.log(upper_lower("Py"));
console.log(upper_lower("JAVAScript"));
function upper_lower(str) {
if (str.length < 3) {
return str.toUpperCase();
}
front_part = (str.substring(0, 3)).toLowerCase();
back_part = str.substring(3, str.length);
return front_part + back_part;
}
console.log(upper_lower("Python"));
console.log(upper_lower("Py"));
console.log(upper_lower("JAVAScript"));
38. Write a JavaScript program to check the total marks of a student in various examinations. The student will get A+ grade if the total marks are in the range 89..100 inclusive, if the examination is "Final-exam." the student will get A+ grade where total marks must be greater than or equal to 90. Return true if the student get A+ grade or false otherwise.
function exam_status(totmarks,is_exam)
{
if (is_exam) {
return totmarks >= 90;
}
return (totmarks >= 89 && totmarks <= 100);
}
console.log(exam_status("78", " "));
console.log(exam_status("89", "true "));
console.log(exam_status("99", "true "));
@javascript_Programming
function exam_status(totmarks,is_exam)
{
if (is_exam) {
return totmarks >= 90;
}
return (totmarks >= 89 && totmarks <= 100);
}
console.log(exam_status("78", " "));
console.log(exam_status("89", "true "));
console.log(exam_status("99", "true "));
@javascript_Programming
39. Write a JavaScript program to compute the sum of the two given integers, If the sum is in the range 50..80 return 65 other wise return 80
function sortaSum(x, y)
{
const sum_nums = x + y;
if (sum_nums >= 50 && sum_nums <= 80) {
return 65;
}
return 80;
}
console.log(sortaSum(30,20));
console.log(sortaSum(90,80));
function sortaSum(x, y)
{
const sum_nums = x + y;
if (sum_nums >= 50 && sum_nums <= 80) {
return 65;
}
return 80;
}
console.log(sortaSum(30,20));
console.log(sortaSum(90,80));
40. Write a JavaScript program to check from two given integers whether one of them is 8 or their sum or difference is 8.
function check8(x, y) {
if (x == 8 || y == 8) {
return true;
}
if (x + y == 8 || Math.abs(x - y) == 8)
{
return true;
}
return false;
}
console.log(check8(7, 8));
console.log(check8(16, 8));
console.log(check8(24, 32));
console.log(check8(17, 18));
function check8(x, y) {
if (x == 8 || y == 8) {
return true;
}
if (x + y == 8 || Math.abs(x - y) == 8)
{
return true;
}
return false;
}
console.log(check8(7, 8));
console.log(check8(16, 8));
console.log(check8(24, 32));
console.log(check8(17, 18));
Lockdown extended till 3rd May 2020
Be safe and Stay at home
Be safe and Stay at home
42. Write a JavaScript program to check whether three given numbers are increasing in strict mode or in soft mode.
function number_order(x, y, z ) {
if ( y > x && z > y)
{
return "strict mode";
}
else if(z > y)
return "Soft mode";
else
return "Undefinded";
}
console.log(number_order(10,15,31));
console.log(number_order(24,22,31));
console.log(number_order(50,21,15));
function number_order(x, y, z ) {
if ( y > x && z > y)
{
return "strict mode";
}
else if(z > y)
return "Soft mode";
else
return "Undefinded";
}
console.log(number_order(10,15,31));
console.log(number_order(24,22,31));
console.log(number_order(50,21,15));
43. Write a JavaScript program to check from three given numbers (non negative integers) that two or all of them have the same rightmost digit.
function same_last_digit(p, q, r) {
return (p % 10 === q % 10) ||
(p % 10 === r % 10) ||
(q % 10 === r % 10);
}
console.log(same_last_digit(22,32,42));
console.log(same_last_digit(102,302,2));
console.log(same_last_digit(20,22,45));
function same_last_digit(p, q, r) {
return (p % 10 === q % 10) ||
(p % 10 === r % 10) ||
(q % 10 === r % 10);
}
console.log(same_last_digit(22,32,42));
console.log(same_last_digit(102,302,2));
console.log(same_last_digit(20,22,45));
44. Write a JavaScript program to check from three given integers that whether a number is greater than or equal to 20 and less than one of the others.
function lessby20_others(x, y, z)
{
return (x >= 20 && (x < y || x < z)) ||
(y >= 20 && (y < x || y < z)) ||
(z >= 20 && (z < y || z < x));
}
console.log(lessby20_others(23, 45, 10));
console.log(lessby20_others(23, 23, 10));
console.log(lessby20_others(21, 66, 75));
function lessby20_others(x, y, z)
{
return (x >= 20 && (x < y || x < z)) ||
(y >= 20 && (y < x || y < z)) ||
(z >= 20 && (z < y || z < x));
}
console.log(lessby20_others(23, 45, 10));
console.log(lessby20_others(23, 23, 10));
console.log(lessby20_others(21, 66, 75));
45. Write a JavaScript program to check two given integer values and return true if one of the number is 15 or if their sum or difference is 15.
function test_number(x, y) {
return (x === 15 || y === 15 || x + y === 15 || Math.abs(x - y) === 15);
}
console.log(test_number(15, 9));
console.log(test_number(25, 15));
console.log(test_number(7, 8));
console.log(test_number(25, 10));
console.log(test_number(5, 9));
console.log(test_number(7, 9));
console.log(test_number(9, 25));
function test_number(x, y) {
return (x === 15 || y === 15 || x + y === 15 || Math.abs(x - y) === 15);
}
console.log(test_number(15, 9));
console.log(test_number(25, 15));
console.log(test_number(7, 8));
console.log(test_number(25, 10));
console.log(test_number(5, 9));
console.log(test_number(7, 9));
console.log(test_number(9, 25));
46. Write a JavaScript program to check two given non-negative integers that whether one of the number (not both) is multiple of 7 or 11.
function valCheck (a, b) {
if (!((a % 7 == 0 || a % 11 == 0) && (b % 7 == 0 || b % 11 == 0))) {
return ((a % 7 == 0 || a % 11 == 0) || (b % 7 == 0 || b % 11 == 0));
}
else
return false;
}
console.log(valCheck(14, 21));
console.log(valCheck(14, 20));
console.log(valCheck(16, 20));
function valCheck (a, b) {
if (!((a % 7 == 0 || a % 11 == 0) && (b % 7 == 0 || b % 11 == 0))) {
return ((a % 7 == 0 || a % 11 == 0) || (b % 7 == 0 || b % 11 == 0));
}
else
return false;
}
console.log(valCheck(14, 21));
console.log(valCheck(14, 20));
console.log(valCheck(16, 20));
Javascript Tutorial:
https://www.youtube.com/watch?v=wm6LNo6715o&list=PLcGjb_nf4rNwdtG7JP0j0qcgAZ74b4-5A
Node js tutorail:
https://www.youtube.com/watch?v=XkpbjI_GyJo&list=PLcGjb_nf4rNxR1eCFakb_-4TUA4FCOW9q
https://www.youtube.com/watch?v=wm6LNo6715o&list=PLcGjb_nf4rNwdtG7JP0j0qcgAZ74b4-5A
Node js tutorail:
https://www.youtube.com/watch?v=XkpbjI_GyJo&list=PLcGjb_nf4rNxR1eCFakb_-4TUA4FCOW9q
YouTube
JavaScript Tutorial for Beginners In Hindi
#javascript_tutorial #javascript_tutorial_in_hindi #logical_programming
Are you new to JavaScript and eager to start your coding journey? Look no further! In this comprehensive JavaScript tutorial, we'll take you from the very basics to more advanced concepts…
Are you new to JavaScript and eager to start your coding journey? Look no further! In this comprehensive JavaScript tutorial, we'll take you from the very basics to more advanced concepts…
https://youtu.be/osLDmH6KBmQ
Explore detailed insight of tree shaking in javascript to boost your application 10x times faster.
Explore detailed insight of tree shaking in javascript to boost your application 10x times faster.
YouTube
Tree Shaking In Javascript With Demo || Optimize Your Nodejs, React, Angular, Vue App
#treeshaking #deadcoderemoval #webpack #optimization
Learn all about tree shaking in JavaScript and how to leverage this powerful technique to remove dead code from your projects, resulting in faster load times and smaller bundle sizes. Discover the best…
Learn all about tree shaking in JavaScript and how to leverage this powerful technique to remove dead code from your projects, resulting in faster load times and smaller bundle sizes. Discover the best…
Webscraping of flipkart product using node js with practical example.
https://youtu.be/_Q0EMB1McXE
Please like, share and subscribe
https://youtu.be/_Q0EMB1McXE
Please like, share and subscribe
YouTube
How to scrap web using nodejs with demo
#webscraping #cheerio #nodejs
Learn how to perform web scraping using Node.js in this comprehensive tutorial.
We'll cover following points
- Web scraping Introduction
- Installtion of cheerio with nodejs
- Scrap data of flipkart products
Whether you're…
Learn how to perform web scraping using Node.js in this comprehensive tutorial.
We'll cover following points
- Web scraping Introduction
- Installtion of cheerio with nodejs
- Scrap data of flipkart products
Whether you're…
MySQL complete course for beginners
https://www.youtube.com/playlist?list=PLcGjb_nf4rNwjUe74arheIyIRJqdIjh1B
https://www.youtube.com/playlist?list=PLcGjb_nf4rNwjUe74arheIyIRJqdIjh1B