Posts

JavaScript Challenge- 11

 /* 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)                 ...

JavaScript Challenge-10

 /*      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);

JavaScript Challenge-9

 /* 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);

JavaScript Coding Challenge-8

 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);

JavaScript Challenge - 7

 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);

Print the Inital Letters of First Name and Last Name

let name = "Rana Saha"; let str; let str1; let str2; str = name.split(" "); for(var i=0; i<name.length; i++){  str1 = str[0][0];  str2 = str[1][0]; } console.log(str1+str2);