<repo_name>ashitosh098/js_week1_function_API-task<file_sep>/anonymous_function/titleCap.js
//anonmyous function to rotate array by k times
var titleCap = function (){
 //create array of string   
var arr=["ChilBule", "AshitoSH", "GUVI"]
//apply map method on string
var title =arr.map((ar)=>{
//convert all characters to lower case    
var lower =ar.toLowerCase().split("");
//convert first character to upper case
var first = lower.shift().toUpperCase();
lower.unshift(first);
var ans =lower.join("");
return ans;
})
//display result
console.log(title);
}
//call anonmyous function
titleCap();<file_sep>/weather.js
//lat lang value as a input
var lat=54;
var lng =-1;
//create a object of  XMLHttprequest
var request = new XMLHttpRequest()
var url ='https://api.openweathermap.org/data/2.5/weather?lat='+lat+'&lon='+lng+'&appid=e4239a13ec2249d41db473766d8cd69d';
//initialize newly created request
request.open('GET',url,true);
//send request to server
request.send();
//execute callback function after transaction is complete 
request.onload  = function()
{
    var data =JSON.parse(this.response);
    console.log("WEATHER REPORT of latitude "+lat+" and longitude "+lng +" : "+data.weather[0].description);
  
    
}
<file_sep>/IIFE_function/Sum_Of_Number.js
//iife function to print sum of all number in array
( function(){
    

    //create array with input number
    var number = [1,2,3,4,5];
    //apply array method reduce on number array
    var ans =number.reduce((sum,current)=>{
        return sum+current;
       }
       );
    //display result 
    console.log(ans);
    

    }
)
//immediately call iife function
();
<file_sep>/IIFE_function/OddNumber.js
//iife function to print odd number in array
( 
    function()
{
    //create array with input number
    var number = [1,2,3,4,5];
    //apply array method filter on number array
    var ans =number.filter(num=>num%2!=0);
    //display result array
    console.log(ans);
    

}
)
//immediately call iife function
();
<file_sep>/IIFE_function/titleCap.js
//IIFE  function to rotate array by k times
(function (){
    //create array of string   
   var arr=["ChilBule", "AshitoSH", "GUVI"]
   //apply map method on string
   var title =arr.map((ar)=>{
   //convert all characters to lower case    
   var lower =ar.toLowerCase().split("");
   //convert first character to upper case
   var first = lower.shift().toUpperCase();
   lower.unshift(first);
   var ans =lower.join("");
   return ans;
   })
   //display result
   console.log(title);
   })
   //call IIFE function
   ();<file_sep>/anonymous_function/Sum_Of_Number.js
//anonymous function to print sum of all  number in array

var sum =   function()
{
    //create array with input number
    var number = [1,2,3,4,5];
    //apply array method reduce on number array
    var ans =number.reduce((sum,current)=>{
     return sum+current;
    }
    );
    //display result
    console.log(ans);
    

}

// call anonymous  function using variable name assigned to it
sum ();
<file_sep>/anonymous_function/OddNumber.js
//anonymous function to print odd number in array

  var odd =   function()
{
    //create array with input number
    var number = [1,2,3,4,5];
    //apply array method filter on number array
    var ans =number.filter((num)=>{
     return num%2!=0
    }
    );
    //display result array
    console.log(ans);
    

}

// call anonymous  function using variable name assigned to it
odd ();
<file_sep>/IIFE_function/prime_number.js
//iife function to print prime number in array
( function (){
    //create array with input number
var number = [1,2,3,4,5,6,17,19,18,24,25,33,24,47,98,93];
//apply array method filter on number  array
var ans = number.filter((num)=>
{
  
  var flag =0;
  //if input number is 2 it is prime number
if(num==2)
{
    return num;
}
//for input number greater than 2
else if(num>2)
{
    //for number>2 and odd 
    if(num%2!=0)
    {
        //check for every number less than input number wether its divide input number or not
       for(i=num-1;i>=2;i--)
       {
           if(num%i!=0)
           {
              flag =flag+1; 
           }
       }
       //if it is not divisible by any other number it is prime
       if(flag==num-2)
       {
           return num;
       }
    }
}
}
)
//display  result
console.log(ans);
}
)
//call iife function
();<file_sep>/anonymous_function/Palindromes.js
//anonmoyus function to find palindromes
var palindromes =function()
{
    //create array
    var arr = ["121","16461","131","126","141","127"];
    //apply array method filter on arr
var ans = arr.filter((num)=>
{
    //split current element of arr
    var temp = num.split("");
    var a=[];
    //push current element of arr in reverse order
    for(var i=temp.length-1;i>=0;i--)
    {
        a.push(temp[i]);
    }
    var b = a.join("");
    //compare current element of arr and its reverse order
    if(+num==+b)
    {
        return num;
        
    }
})
//display result array
console.log(ans);
}
//call anonmoyus function
palindromes();