-
write a script to print all array values in the console.
-
For the Given array: [23,34,54,0,4,7]
print all the Array values using a for loop.
Expected output: 23 34 54 0 4 7
-
print all numbers in an array except the first element.
Expected output: 34 54 0 4 7
-
Print all elements in an array except the last element
Expected output: 23 34 54 0 4
-
Print all the numbers from last index to first index
Expected output: 7 4 0 54 34 23
-
Print all the numbers from last index to first index except the first element
Expected output: 4 0 54 34 23
-
Print all the numbers from last index to first index except the last element
Expected output: 7 4 0 54 34
-
Print only the last 4 elements of an array.
Expected output: 54 0 4 7
-
For the Given array: [23,34,54,10,4,7] print the minimum number in an Array.
Expected output: 4
-
For the Given array: [23,34,54,10,4,7] print the Maximum number in an array.
Expected output: 54
-
For the Given array: [23,34,54,10,4,7] sum of all the numbers in an Array.
Expected output: 132
-
For the Given array: [23,34,54,10,4,7] Average of all the numbers in an Array.
Expected output: 22
-
For the Given array: [23,34,54,10,4,7] print values that are greater than the given number.
Given number: 20, Expected output: 23,34,54
-
For the Given array: [23,34,54,10,4,7] print all the even numbers in an Array.
Expected output: 34,54,10,4
-
For the Given array: [23,34,54,10,4,7] print all the odd numbers in an Array.
Expected output: 23,7
-
For the Given array: [23,-34,-54,10,-4,7] print all the positive numbers in an array.
Expected output: 23,10,7
-
For the Given array: [23,34,54,10,4,7] search if the given number is there in an array or not.
Given number: 34, Expected output: true
Given number: 26, Expected output: false
-
For the Given array: [23,34,54,10,34,7,23,10,34] print the total number of times an element
found in the array.
Given number: 23, Expected output: 2
Given number: 34, Expected output: 3
Given number: 10, Expected output: 2
Given number: 54, Expected output: 1
-
For the Given array: [23,34,54,10,4,7] print index of a given element in an Array.
Given number: 23, Expected output: 0
Given number: 34, Expected output: 1
Given number: 10, Expected output: 3
Given number: 54, Expected output: 2
-
For the Given array: [23,34,54,10,34,7,23,10,34] eliminate duplicates in a given array
Expected output: 23,34,54,10,7
-
a program to store an array into another array
var ar = [23,34,54,10,4,7]
var br = [ ]
Expected output: br = [23,34,54,10,4,7]
-
Sort an array in ascending order.
Given array: [23,34,54,10,4,7]
Expected output: 4,7,10,23,34,54
-
Reduce the each element of the array by 25% and store in a separate array.
-
Store only even numbers of a given array in another array.
-
create a duplicate array for a given array.
-
Eliminate duplicates from a array
-
print only the perfect squares in an array
-
Print only the 2 digit numbers from an array
-
Print only multiples of 5 from an array
-
Print only multiples of 2 AND 3 from an array
-
Print only multiples of 3 OR 5 from an array
-
Increment 5% for all the salaries in a given array
-
For every basic salary present in the array, add 40% HRA, 92% DA, 10% Tax and display the final
output
-
For every salary, deduct 10% tax for salaries less than 50000 and deduct 12% tax for salaries
more than 50000
-
Print only those odd numbers in a given array which are divisible by 3.
-
Insert first 10 odd numbers in an empty array(for and while).
-
Print the elements present in the second half of the array.
-
Print the greatest of all 2-digit numbers present in an array.
-
Write a program to remove elements from an array which are not in the ascending order
Ex:
Original array: [12,34,11,56,37,98,23,67,109,45]
Output : [12,34,56,98,109]
-
Write a program to sort the array based on the number of occurrences of elements
Ex: original array: [1,2,5,6,2,1,6,1,2,6,2,1,2];
After the logic:
[5,6,6,6,1,1,1,1,2,2,2,2,2];
//5 occurred one time,6 three times,1 occurred 4 times, 2 occurred 5 times
-
var ar = [19,12,23,4,15];
var br = [26,37,18,79,10];
a)Write script to merge array as the values of ar in the first and values of br next
Expected output: [19,12,23,4,15,26,37,18,79,10];
b)Write script to merge array as the values of ar in the first and values of br next
Expected output: [26,37,18,79,10,19,12,23,4,15];
-
var ar = [1,2,3,7,8,9];
var br = [4,5,6];
Expected output: [1,2,3,4,5,6,7,8,9];
-
insert An Element Desired or Specific Position In An Array
-
Remove Duplicates Items In An Array
-
Delete Element From Array At Desired Or Specific Position
-
Check String Is Palindrome Or Not Using For Loop
-
Convert All Input String Simultaneously Into Asterisk ( * )
-
Read and print elements of the array. – using recursion.
-
Print all negative elements in an array.
-
Sum of all array elements. – using recursion.
-
Find a maximum and minimum element in an array. – using recursion.
-
Get the second largest element in an array.
-
Count the total number of even and odd elements in an array.
-
Count the total number of negative elements in an array.
-
Copy all elements from an array to another array.
-
Insert an element in an array.
-
Delete an element from an array at the specified position.
-
Count frequency of each element in an array.
-
Print all unique elements in the array.
-
Count the total number of duplicate elements in an array.
-
Delete all duplicate elements from an array.
-
Merge two arrays to the third array.
-
Find the reverse of an array.
-
Put even and odd elements of an array in two separate arrays.
-
Search an element in an array.
-
Sort array elements in ascending or descending order.
-
Sort even and odd elements of the array separately.
-
Right rotate an array.
Working with Object Literals
-
Given an object:
var person = {
"firstName" : "Harry",
"lastName" : "Potter",
"age": 30,
"gender": "male",
"skill" : "ReactJS",
"expertise": "Beginner"
};
-
Print the firstname.
-
Print the lastname.
-
Print the fullname("Harry Potter").
-
If the age is less than 18, then print "false". If the age is more than 18, then print "true".
-
For the given marks object solve the following
var marks = {
"maths" : 34,
"english" : 56,
"science": 32,
"hindi" : 75,
"social science": 65
};
-
Print the marks of all the subjects.
-
Print the names of all the subjects from the given object.
-
Count the number of subjects from the given object.
-
Print the percentage of the marks of the student.
-
Print only those subjects where the student scored more than 35.
-
Print the pass/fail status of the subjects provided 35 is the pass mark.
-
Print only the passed subjects.
-
Count the number of passed subjects.
-
Print only the failed subjects.
-
Count the number of failed subjects.
-
Print the least scored subject.
-
Print the highest scored subject.
-
Check whether the student has passed in all the subjects or not.
-
Take the subject name from the student through prompt box and print the subject marks
and pass/fail status.
-
For the given Object Solve the following
var products = [
{
"name": "Duracell - AAA Batteries (4-Pack)",
"type": "HardGood",
"price": 5.49,
"category": "Household Batteries",
"manufacturer": "Duracell",
},
{
"name": "Hard Rock TrackPak - Mac",
"type": "Software",
"price": 29.99,
"category": "Recording Equipment",
"manufacturer": "Hal Leonard",
},
{
"name": "Duracell - AA 1.5V CopperTop Batteries (4-Pack)",
"type": "HardGood",
"price": 5.62,
"category": "Household Batteries",
"manufacturer": "Duracell",
},
{
"name": "Energizer - MAX Batteries AA (4-Pack)",
"type": "HardGood",
"price": 5.32,
"category": "Household Batteries",
"manufacturer": "Energizer",
},
{
"name": "METRA - Antenna Cable Adapter - Black",
"type": "HardGood",
"price": 13.99,
"category": "Antennas & Adapters",
"manufacturer": "Metra",
},
{
"name": "WipeDrive Six - Mac|Windows",
"type": "Software",
"price": 23.99,
"category": "Maintenance Software",
"manufacturer": "White Canyon",
}
];
-
Print all the product names.
-
Print all the hardgoods.
-
Print all the softwares.
-
Print all the categories.
-
Print only the products manufactured by Duracell.
-
Print the product names in ascending order of their prices.
-
Print only those products whose price is more than 14.99.
-
Print only those products whose price is less than 9.99.
-
Print the total price of all the hardgoods.
-
Print the average price of the softwares.
-
var people = [
{
"firstname": "praveen",
"lastname": "gubbala",
"age": 36,
"gender": "male",
"city": "hyd",
"salary": 10000
},
{
"firstname": "srikanth",
"lastname": "gubbala",
"age": 32,
"gender": "male",
"city": "bengaluru",
"salary": 20000
},
{
"firstname": "pradeep",
"lastname": "reddy",
"age": 21,
"gender": "male",
"city": "hyd",
"salary": 30000
},
{
"firstname": "mounika",
"lastname": "mudiraj",
"age": 20,
"gender": "female",
"city": "nalgonda",
"salary": 30000
},
{
"firstname": "nikhil",
"lastname": "m",
"age": 22,
"gender": "male",
"city": "guntur",
"salary": 2000
},
{
"firstname": "riya",
"lastname": "bhadouria",
"age": 14,
"gender": "female",
"city": "indore",
"salary": 40000
}
];
-
Print all the firstnames.
-
Print all the full names.
-
Print only those names whose age is more than 25.
-
Print all female names.
-
Print only those names whose salary is more than 30000 and increase their salaries by
15%.
-
Using prompt, print only those names whose city is "hyd".
-
Print the total salary of all the people.
-
Print all the female names.
-
Print all the firstnames whose salary is more than 30000.
-
Using prompt, print all names whose city is "hyd".
-
Print all the fullnames in the alphabetical order.
-
Print all the fullnames in the increasing order of their age.
-
Print all the fullnames in the reverse alphabetical order.
-
Print all the fullnames in the decreasing order of their salaries.
-
Print all the cities in which the people live. There should not be any duplicate cities.
-
Print all the male names whose age is greater than 25.
-
Print all names that starts with "p" and the firstname should be in UPPERCASE. e.g.
PRAVEEN gubbala.
Working with Strings
-
Find the first occurrence of a character in a given string.
-
Find the last occurrence of a character in a given string.
-
Search all occurrences of a character in a given string.
-
Count occurrences of a character in a given string.
-
Find the highest frequency character in a string.
-
Find the lowest frequency character in a string.
-
Count the frequency of each character in a string.
-
Remove the first occurrence of a character from a string.
-
Remove the last occurrence of a character from a string.
-
Delete all occurrences of a character from a string.
-
Remove all repeated characters from a given string.
-
Replace the first occurrence of a character with another in a string.
-
Replace the last occurrence of a character with another in a string.
-
Put all occurrences of a character with another in a string.
-
Find the first occurrence of a word in a given string.
-
Find the last occurrence of a word in a given string.
-
Search all occurrences of a word in a given string.
-
Count occurrences of a word in a given string.
-
Remove the first occurrence of a word from the string.
-
Remove the last occurrence of a word in a given string.
-
Delete all occurrence of a word in a given string.
-
A Trim leading white space characters from a given string.
-
Trim trailing white space characters from a given string.
-
Trim both leading and trailing white space characters from a given string.
-
Remove all extra blank spaces from the given string.
-
A String is Palindrome or Not
-
A String Is an Anagram or Not
-
Find the length of a string.
-
Copy one string to another string.
-
Concatenate two strings.
-
Compare two strings.
-
Convert lowercase string to uppercase.
-
Convert uppercase string to lowercase.
-
Toggle case of each character of a string.
-
Find a total number of alphabets, digits or special character in a string.
-
Count the total number of vowels and consonants in a string.
-
Count the total number of words in a string.
-
Find the reverse of a string.
-
Check whether a string is a palindrome or not.
-
Reverse order of words in a given string.
-
Reverse of a number using toString, split, reverse and join methods.
-
Elimination of zeroes from a given number.
-
Find the number of digits of a given number using toString() and length property
-
Write a program to take a string and print only the numeric characters using. Example:
Input->‘Q1STR5684AK’; Output->‘15684’
-
Search for a given number in an array
-
Print the number of words in a given string
-
Remove the single spaces from a given sentence
-
remove all the spaces from a given string
-
Search a given string in a sentence(both uppercase and lowercase)
-
Write a program to convert a sample sentence string into an array of all the words in the
sentence. Example: Input->‘Hello World’; Output->[‘Hello’,‘World’]
-
Write a program to eliminate all numeric characters from a string. Example: Input->‘Q1STR5684A’;
Output-> ‘QSTRAK’
-
Write a program to take a string and print only the numeric characters. Example:
Input->‘Q1STR5684AK’; Output->‘15684’
-
Write a program to take a string and print the number of characters in the string. Example:
Input->‘Hello’; Output->5
-
Write a program to take a 16-digit credit card number and replace the first 12 characters with
‘X’. Example:Input->‘9765143265387960’; Output->‘XXXXXXXXXXXX7960’
-
Write a program to take a string and replace all vowels with ‘8’. Example: Input->‘This is
awesome’; Output->‘Th8s 8s 8w8s8m8’
-
Write a program to hide the middle six digits of a phone number. Example: Input-> '9876543210';
Output-> '98XXXXXX10'
-
Append the calling code of India(+91) to a given phone number. Example: Input-> '9876543210';
Output-> '+919876543210'
-
Check whether a given number is a valid phone number.
Example:Input-> '7654893274'; Output-> 'valid'
Input-> '785487438754'; Output-> 'invalid'.........(must be 10 digits)
Input-> '7854s54839'; Output-> 'invalid'.............(must NOT contain letters)
-
Check whether a given number is a valid credit card number. Example:
Example:
Input-> '7463836483647454'; Output-> 'valid'
Input-> '74638364836474548'; Output-> 'invalid'...(must be 16 digits)
Input-> '7463836w4836o745'; Output-> 'invalid'...(must contain only numbers)
-
Write a program to add hyphens (-) in between a given credit card number.
Example:
Input-> '6484638463487486'; Output-> '6484-6384-6348-7486'
-
Sort a given string
Example: ‘praveen’=>’aeenprv’
-
Eliminate Duplicate characters in given string
Example: ‘praveengubbala’ => ‘pravengubl’
-
Write a program to print only numbers out of a given string
Example: let us take pr34s2v9q4
The output should be 3,4,2,9,4