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

Manufacturing Date


Given a expiry date

expiryDate and number of months before expiry monthsBeforeExpiry of a product, write a JS program to find the manufacturing date.
Input

  • The first line of input contains a date string expiryDate
  • The second line of input contains a number monthsBeforeExpiry

Output

  • The output should be a single line containing the manufacturing date of the product


Sample Input 1

2020-01-21

8


Sample Output 1

21-5-2019


Sample Input 2

2021-11-12

2


Sample Output 2

12-9-2021




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


Sample Input 2

180

1


Sample Output 2

180




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




Check values in the Array is a String

Given an array

myArray, write a JS program to check whether each value of the array is a string or not using the array method every().Input

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

Output

  • The output should be a single line containing a boolean value

Sample Input 1

[ 'frozen', 'rock', 'stained', 'basket' ]

Sample Output 1

true

Sample Input 2

[ 'recycling', 70, 'pastime', 'animal' ]

Sample Output 2

false






Given two boolean values 
isGrassTrimmerFound and isWaterHosePipeFound as inputs, create three JS promises using async/await and try/catch blocks.
For cutting the grass,
resolve with "Grass Trimmed" text, if the isGrassTrimmerFound is true
reject with "Grass Trimmer Not Found" text, if the isGrassTrimmerFound is false
For cleaning the garden,
resolve with "Garden Cleaned" text
For watering the plants,
resolve with "Watered Plants" text, if the isWaterHosePipeFound is true
reject with "Water Hose Pipe Not Found" text, if the isWaterHosePipeFound is false
Input
The first line of input contains a boolean isGrassTrimmerFound
The second line of input contains a boolean isWaterHosePipeFound
Sample Input 1
true
true
Sample Output 1
Grass Trimmed
Garden Cleaned
Watered Plants
Sample Input 2
true
false
Sample Output 2
Grass Trimmed
Garden Cleaned
Water Hose Pipe Not Found
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


Trekking Kit

Given an object 

trekkingKit in the prefilled code and item item as an input, write a JS program to add the method isKitContains to the constructor function Trekking using the prototype.

The method 

isKitContains checks whether the trekkingKit contains the given item.

Quick Tip
The Object.getOwnPropertyNames() method gives an array containing the properties of the object.
Input

The input will be a single line containing a string 

item

Output

The output should be a single line containing a boolean value

Sample Input 1
ruckSackBag
Sample Output 1
true

Sample Input 2
surfboard
Sample Output 2
false
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


In this assignment, let's build a Book Search page by applying the concepts we learned till now.

Refer to the below image.


The page should perform the operation as shown in the following image link:-

https://assets.ccbp.in/frontend/content/dynamic-webapps/bookmark-maker-output.gif


Instructions:

  • Add HTML input element with id searchInput inside an HTML container element
  • Add HTML select element with id selectDisplayCount inside an HTML container element
  • Add HTML container element with id searchResults


Resources

Use this Background image:

https://assets.ccbp.in/frontend/dynamic-webapps/book-search-bg.png

CSS Colors used:

Text colors Hex code values used:

#323f4b

#ffffff


CSS Font families used:

  • Roboto


please help me.


Manufacturing Date

Given a expiry date

expiryDate and number of months before expiry monthsBeforeExpiry of a product, write a JS program to find the manufacturing date.Input

  • The first line of input contains a date string expiryDate
  • The second line of input contains a number monthsBeforeExpiry

Output

  • The output should be a single line containing the manufacturing date of the product


"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();

});


function readLine() {

 return inputString[currentLine++];

}


/* Please do not modify anything above this line */


function main() {

 const expiryDate = new Date(readLine());

 const monthsBeforeExpiry = parseInt(readLine());


 const manufacturingDate = /* Write your code here */


/* Please do not modify anything below this line */

 console.log(`${manufacturingDate.getDate()}-${manufacturingDate.getMonth() + 1}-${manufacturingDate.getFullYear()}`);

}


LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS