Search Item in a Mart
Given an array
mart of objects in the prefilled code and categoryOfItem, item as inputs, create a JS promise,
resolve with "Item Found" text, if the
categoryOfItem matches with the category and the corresponding items list includes the item
reject with "Category Not Found" text, if the
categoryOfItem does not match with any catergory in the mart
reject with "Item Not Found" text, if the
items list does not include item
Use async/await and try/catch blocks.
Quick Tip
You can use array methods find() and includes().
Input
The first line of input contains a string categoryOfItem
The second line of input contains a number item
Output
The output should be a single line string with the appropriate message
Sample Input 1
pulses
green gram
Sample Output 1
Item Found
Sample Input 2
detergents
tide
Sample Output 2
Category Not Found
Unite Family
Given three objects
Sample Input
{'surname' : 'Jones', 'city': 'Los Angeles'}
{'dish': 'puddings'}
{'pet': 'Peter'}
Sample Output
Mr and Mrs Jones went to a picnic in Los Angeles with a boy and a pet Peter. Mrs Jones made a special dish "puddings"
String Slicing
Given two strings
Sample Input 1
JavaScript
S
Sample Output 1
Script
Sample Input 2
Language
air
Sample Output 2
Language
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (inputStdin) => {
inputString += inputStdin;
});
process.stdin.on("end", (_) => {
inputString = inputString.trim().split("\n").map((str) => str.trim());
main();
});
Custom Input
RUN CODE
SUBMIT
Series of Operations
Given an array
Sample Input
[ 12, 2, 2, 4, 1 ]
Sample Output
616 -14 -14 112 -77
Split and Replace
Given three strings
inputString, separator and replaceString as inputs. Write a JS program to split the
inputString with the given separator and replace strings in the resultant array with the replaceString whose length is greater than 7.
Quick Tip
Sample Input 1
JavaScript-is-amazing
-
Programming
Sample Output 1
Programming is amazing
Sample Input 2
The&Lion&King
&
Tiger
Sample Output 2
The Lion King
how it is possible two outputs(sample output 1, sample output 2) in this program
Submarine
Given two numbers
The sequence of operations is,
Sample Input 1
5
2
Sample Output 1
Submarine Submerged
2 Torpedos Fired, 3 Left
Submarine Surfaced
Sample Input 2
10
2
Sample Output 2
Submarine Submerged
2 Torpedos Fired, 8 Left
Submarine Surfaced
Unite Family
Given three objects
Area and Circumference of a Circle
Given radius
radius of a circle, write a JS constructor function with the methods getArea and getCircumference to calculate the area and circumference of the circle.
Note
The value of π = 3.14
Quick Tip
Use the formulae to calculate,
Sample Input 1
7
Sample Output 1
153.86
43.96
Sample Input 2
25
Sample Output 2
1962.5
157
Hotel Bill
A Hotel is offering discounts to its customers.
Given charge per day
dayCharge based on category and numbers of days customer stayed days as inputs, write a JS arrow function to return the total bill with the discount.
Quick Tip
Apply discounts on the following basis,
Sample Input 1
200
3
Sample Output 1
570
getting 600 but actual output is 570.
Sample Input 2
180
1
Sample Output 2
180