Professional Documents
Culture Documents
var arr=['Ram','Manas','Komali','Rajesh'];
arr.pop();
</script>
var arr=[12,78,14,20,62];
arr.pop();
arr.push(25);
</script>
4.Write a Javascript program to create an array of online orders of Mc Donalds
on basis of their first come first serve basis and return the remaining pending
orders after the first order is out for delivery.
Input: ['Burger', 'Sandwich', 'fries', 'Coffee']
Output: ['Sandwich', 'fries', 'Coffee']
Program:
<script>
var arr=['Burger','Sandwich','Fries','Coffee'];
arr.shift(0);
</script>
var arr=['Vijayawada','Khammam','Warangal','Hyderabad'];
console.log("stations "+arr);
</script>
6.Write a Javascript program to create an array of even numbers and add an odd
number "25" in the beginning of the array.
Input: [12,18,22,34,48,72]
Output: [25,12,18,22,34,48,72]
Program:
<script>
var arr=[12,18,22,34,48,72];
console.log("before "+arr);
arr.unshift(25);
console.log("after "+arr);
</script>
7.Write a Javascript program create an array of given input and return the
length of the array
Input: [Chair, Table, Cupboard, Bench, Door[
Output:5
Program:
<script>
var arr=['Chair','Table','Cupboard','Bench','Door'];
</script>
8.Write a Javascript program to create an array of boys and return the array after
deleting the first and last elements in the array.
Input: ['Manish', 'Adarsh', 'Sameer', 'Raman', 'Bhaskar','Teja']
Output: [ 'Adarsh', 'Sameer', 'Raman', 'Bhaskar']
Program:
<script>
var arr=['Manish','Adarsh','Sameer','Raman','Bhaskar','Teja'];
console.log("before "+arr);
arr.shift();
arr.pop();
console.log("after "+arr);
</script>
var arr=['Reliance','Titan','Wipro','Bajaj'];
console.log("before "+arr);
arr.splice(2,0,'Cipla','ITC');
console.log("after "+arr);
</script>
var arr=[10,14,74,45,52,56,47,40,21];
console.log("before "+arr);
arr.splice(2,3);
console.log("After "+arr);
</script>
11.Write a javascript program to find the youngest driver age among the given
array of ages of the drivers.
Input: [45,51,36,28,25,17,19,20,25]
Output: 17
Program:
<script>
var arr=[45,51,36,28,25,17,19,20,25];
console.log("array "+arr);
arr.sort();
</script>
12.Write a javascript program to find the name "Radha" from array of the log
register of the Employee and return found if you find.
Input: ['Ravali', 'Rakesh', 'Suman', 'Saikiran', 'Radha', 'Rani']
Output: found
Program:
<script>
var arr=['Ravali','Rakesh','Suman','Saikiran','Radha','rani'];
function finding(arr)
{
if(arr=='Radha')
return true;
else
return false;
var op=arr.find(finding);
if(op=='Radha')
console.log('Found');
else
console.log('not found');
</script>
13.Write a javascript program to create Voters age array. find if the age less
than 18 from array and delete it.
Return the array.
Input:[20,45,31,39,17,19,40,34,18]
Output:[20,45,31,39,19,40,34,18]
Program:
<script>
var arr=[20,45,31,39,17,19,40,34,18];
function checkAge(age)
return age>=18;
}
var aged=arr.filter(checkAge);
console.log(aged);
</script>
var arr=['milk','eggs','bread','butter','cheese','sugar'];
function findindex(ip)
if(ip=='cheese')
return true;
Else
return false;
var op=arr.findIndex(findindex);
console.log(op);
</script>
<script>
function car(carCompany,carName,carYear,carColor)
this.carCompany=carCompany;
this.carName=carName;
this.carYear=carYear;
this.carColor=carColor; };
console.log(hyndai);
</script>