/* Write a program to find the Area of a Circle.. */ function CircleArea(rad){ let areaOfCircle = (Math.PI * Math.pow(rad, 2)); console.log(areaOfCircle); } let radius = 7; CircleArea(radius);
/* Write a program to find distance between two places. The Latitude and Longitude of two places will be given. */ function findDistance(curr_lat, curr_long, dest_lat, dest_long){ // Current Latitude & Longitude in Radians.. let lat1_red = curr_lat * (Math.PI/180); let long1_red = curr_long * (Math.PI/180); // Current Latitude & Longitude in Radians.. let lat2_red = dest_lat * (Math.PI/180); let long2_red = dest_long * (Math.PI/180); // Find Distance.. let dlon = long2_red - long1_red; // Distance bet. two Longitudes.. let dlat = lat2_red - lat1_red; // Distance between two Latitude.. let a = Math.pow(Math.sin(dlat/2), 2) ...
/* Create a function that find sum of squares of every digit of a number. Example: - squareDigits(123) ➞ (1^2 + 2^2 + 3^2) = 14 squareDigits(24) ➞ (2^2+4^2) = 20 squareDigits(3212) ➞ (3^2+2^2+1^2+2^2) = 18 */ let num = 428; let digits = num.toString().split(' '); let realDigits = digits.map(Number); let result = 0; for(var i=0; i<realDigits.length; i++){ result = result + ((realDigits[i] * realDigits[i])); } console.log(result);
/* Create a function that takes two arguments: the original price and the discount percentage as integers and returns the final price after the discount. */ let original_price; let discount; let result; function discountedPrice(price, disc){ if(disc<100){ result = ((price)*((100 - disc)))/100; }else{ result = "Please Enter valid value"; } console.log(result); } discountedPrice(2000, 25);
Write a program which removes 0 from prefix but not suffix.. e.g., - if, i/p - 300, (o/p - 300) if, i/p - 003, (o/p - 3) _______________________________________ let original_num; let result; function removeZeros(number){ if(number%10 == 0){ result = original_num; }else{ result = (number%10); } console.log(result); } original_num = 009; removeZeros(original_num);
Create a function that takes a country's name and its area as arguments and returns the area of the country's proportion of the total world's landmass. ------------------------------------------------------------------------------------------------------------ let world_land = 148940000; // (in KM. square) function areaOfLand(country, area){ let country_area = ((area/world_land)*100).toFixed(2); let result = "Area of "+country+" is "+country_area+" % of the total Land Mass"; console.log(result); } areaOfLand("India", 2973190);