Go to the top

Practice Javascript Programs for Interview

Ronit / Blog, Javascript, Technical / 0 Comments
Image of Javascript Programming

Here below I will keep on posting Javascript Programs for Interview because preparing for an interview is something which needs to be planned and done in a focused way. Preparation includes going through theories and practicing the programs.

"Hope it helps you in your journey of Preparation for Interview"

Program #RMJPQ1

OOPS, Private/Public

WAP for Student Management System to manage student data with functionalities as add, edit, delete, bulk activate/deactivate.
The program needs to be object oriented without using ES6+

Program #RMJPQ2

Callback

WAP using the callback to find the sum of all even numbers in a given array.

Input: [10,3,9,6,11,20]

Output: 36

Program #RMJPQ3

Closure

WAP using the closure to multiply 3 numbers;

Input: 3,2,5

Output: 30

Program #RMJPQ4

Array, Function, Object

WAP to find the topper in the class given Student's name and marks in (Maths, Science, English)
The program should find the student and finally print the topper's name with his percentage.

Input:

students = [{
name: "Sumit",
marks: {
english: 60,
maths: 80,
science: 97
}
},
{
name: "Amit",
marks: {
english: 65,
maths: 90,
science: 77
}
}
]

Output: "Sumit has topped the class with 79%"

Program #RMJPQ5

Variable Scoping

What is the output of the following function:-

Output:-

Output of Program
Output of Program

Program #RMJPQ6

Looping, Array, Object

Question:-

WAP to find the total count and name of all adult students in the class from the given data.

Input:-

[{
name: "Ajay",
age: 26
},
{
name: "Amit",
age: 16
},
{
name: "Shikha",
age: 18
},
{
name: "Manish",
age: 62
}
];

Expected Output:-

Total Count:- 3

List of Names: ["Ajay","Shikha","Manish"]

Solution:-

JSFiddle Link:- 

https://jsfiddle.net/mukherjeeronit/bs9k6v37/2/

Program:- 
Actual Output:-
Screenshot of the output of RMPJPQ6

Screenshot of the output of RMPJPQ6

Program #RMJPQ7

Looping, Array, Object

Question:-

WAP to print the list of all students who have more than 1 contact number but are not adult.

Input:-

[{
name: "Ajay",
age: 12,
contact_numbers:[
8647896541,
7489651258
]
},
{
name: "Amit",
age: 16,
contact_numbers:[
8647896541
]
},
{
name: "Shikha",
age: 18,
contact_numbers:[
8647896541,
9745896512,
6589784589
]
},
{
name: "Manish",
age: 62,
contact_numbers:[]
}
];

Expected Output:-

List of Names:- ['Ajay']

Solution:-

JSFiddle Link:- 

https://jsfiddle.net/mukherjeeronit/9rxwt0n5/

Program:- 
Actual Output:-
Screenshot of the output of RMPJPQ7

Screenshot of the output of RMPJPQ7

Program #RMJPQ8

Looping, Array, Object

Question:-

WAP to print the name of the users who have visited the website more than 5 times and also print the total number of visits on the site.

Input:-

[
{
name:"Ronit",
total_visit_count: 4
},
{
name:"Sumit",
total_visit_count: 15
},
{
name:"Amit",
total_visit_count: 5
},
{
name:"Surbhi",
total_visit_count: 10
}
];

Expected Output:-

List of Names:- ['Sumit','Surbhi']
Total Website Visits Count: 34

Solution:-

JSFiddle Link:- 

https://jsfiddle.net/mukherjeeronit/sqbh0aL8/

Program:- 
Actual Output:-
Screenshot of the output of RMPJPQ8

Screenshot of the output of RMPJPQ8

Program #RMJPQ9

Promises, Closures, Looping,  Array, Object

Question:-

WAP to fetch the data of Users(USING API) with their Friends Count, check if any user has more than 500 friends then send them gift(USING API) at their address, and also if the user is a member from more than 1 year then send them a thanking mail(USING API).

User Object Looks As Follows:-
{
name: "Amit",
age: 24,
email: "amit@gmail.com",
address: "112 Street, 7th Avenue, New York",
member_since: 2018,
frnds_count: 600
}

Solution:-

JSFiddle Link:- 

https://jsfiddle.net/mukherjeeronit/4mo7vLet/1/

Program:- 
Actual Output:-
Screenshot of the output of RMPJPQ9

Screenshot of the output of RMPJPQ9