HTML/JavaScript Web Application Answers

Questions: 680

Answers by our Experts: 648

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

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

father, mother, and child, write a JS program to concatenate all the objects into the family object using the spread operator.Input

  • The first line of input contains an object father
  • The second line of input contains an object mother
  • The third line of input contains an object child

Output

  • The output should be a single line string with the appropriate statement as shown in sample outputs

Constraints

  • Keys of the objects should be given in quotes

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

inputString and subString as inputs, write a JS program to slice the inputString if it includes the subString. Slice the inputString starting from the subString to the end of the inputString.Input

  • The first line of input contains a string inputString
  • The second line of input contains a string subString

Output

  • The output should be a sliced string or inputString (if the inputString does not include the subString)

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

  1. myArray of numbers, write a JS program to perform the following steps and log the result. Multiply each value with 9.
  2. Subtract 20 from each value.
  3. Multiply each value with 7.
  4. Log the values of the resulting array separated by a space.

Input

  • The input will be a single line containing an array myArray

Output

  • The output should be a single line with values separated by a space

Constraints

  • Each value in the array must be a number

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

  • You can use the string method split()
  • You can use the array method map()

Input

  • The first line of input contains a string inputString
  • The second line of input contains a string separator
  • The third line of input contains a string replaceString

Output

  • The output should be a single line containing the strings separated by a space

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




father, mother, and child, write a JS program to concatenate all the objects into the family object using the spread operator.Input

how it is possible two outputs(sample output 1, sample output 2) in this program



Submarine

Given two numbers


The sequence of operations is,

  1. Submerge the Submarine
  2. Fire torpedos
  3. Surface the Submarine

Input

  • The first line of input contains a number totalTorpedos
  • The second line of input contains a number torpedosFired

Output

  • The first line of output is a string with Submarine Submerged text
  • The second line of output is a string with the number of torpedos fired and left, as shown in sample outputs
  • The third line of output is a string with Submarine Surfaced text

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

father, mother, and child, write a JS program to concatenate all the objects into the family object using the spread operator.Input

  • The first line of input contains an object father
  • The second line of input contains an object mother
  • The third line of input contains an object child

Output

  • The output should be a single line string with the appropriate statement as shown in sample outputs

Constraints

  • Keys of the objects should be given in quotes

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,

  • Area of circle = π * radius * radius
  • Circumference of circle = 2 * π * radius

Input

  • The input will be a single line containing a number radius

Output

  • The first line of output should contain the area of the circle
  • The second line of output should contain the circumference of the circle

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

  • The formula for bill is,
  • bill = dayCharge * days
  • The formula to calculate the discounted bill,
  • bill - (bill * discount) / 100

Apply discounts on the following basis,

  • 5%, if the customer stays more than 2 days
  • 15%, if the customer stays more than 5 days

Input

  • The first line of input contains a number dayCharge
  • The second line of input contains a number days

Output

  • The output should be a single line containing the total bill with the discount

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




LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS