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

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"


i want code in between write your code here


"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 father = JSON.parse(readLine().replace(/'/g, '"'));

 const mother = JSON.parse(readLine().replace(/'/g, '"'));

 const child = JSON.parse(readLine().replace(/'/g, '"'));

 

 /* Write your code here */ 


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

 console.log(`Mr and Mrs ${family.surname} went to a picnic in ${family.city} with a boy and a pet ${family.pet}. Mrs ${family.surname} made a special dish "${family.dish}"`);

}



Update Pickup Point


Given a previous pickup point in the prefilled code, and updated pickup point

area, city as inputs, write a JS factory function with a method to update the pickup point.
Input

  • The first line of input contains a string area
  • The second line of input contains a string city

Output

  • The output should be a single line containing the updated pickup point area and city separated by a space


Sample Input 1

Kukatpally

Hyderabad

Sample Output 1

Kukatpally Hyderabad

Sample Input 2

Jubilee Hills

Hyderabad

Sample Output 2

Jubilee Hills Hyderabad


i want code in between write code here


"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 createCabBooking(area, city) {


 /* Write your code here */


}


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


function main() {

 const newArea = readLine();

 const newCity = readLine();

  

 const cabBooking1 = createCabBooking("Abids", "Hyderabad");

 cabBooking1.updatePickupPoint(newArea, newCity);


 console.log(`${cabBooking1.area} ${cabBooking1.city}`);

}



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


i want the code in between write code here


"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 dayCharge = JSON.parse(readLine());

 const days = parseInt(readLine());

 

 /* Write your code here */

}


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

 let input = inputString[currentLine++]; 

 return input === undefined ? undefined : JSON.parse(input);

}


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

  

 /* Write your code here */ 

  


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


function main() {

 const principal = readLine();

 const time = readLine();

 const apprPercentage = readLine();


 const finalValue = calculateFinalValueWithAppreciation(principal, time, apprPercentage);


 console.log(finalValue);

}



Final Value with Appreciation

Given principal amount

principal as an input, time period in years time and appreciation percentage apprPercentage as optional inputs, write a JS function to return the final value finalValue with the given appreciation percentage and time period. The default values for time and apprPercentage are 2 and 5 respectively.

Quick Tip

The formula to calculate the final value with appreciation is,

finalValue = principal * (1 + time * appreciation / 100)

Input

  • The first line of input contains a number principal
  • The second line (optional) of input contains a number time
  • The third line (optional) of input contains a number apprPercentage

Output

  • The output should be a single line containing the finalValue


Sample Input 1

1000

2

3


Sample Output 1

1060


Sample Input 2

3000


Sample Output 2

3300.0000000000005



String Starts or Ends with given String

Given an array

stringsArray of strings, and startString, endString as inputs, write a JS program to filter the strings in stringsArray starting with startString or ending with endString.

Quick Tip

You can use the array method filter() and logical operator OR ( || ).


Input

  • The first line of input contains a string stringsArray
  • The second line of input contains a string startString
  • The third line of input contains a number endString

Output

  • The output should be a single line containing an array of filtered strings


Sample Input 1

['teacher', 'friend', 'cricket', 'farmer', 'rose', 'talent', 'trainer']

t

r


Sample Output 1

[ 'teacher', 'farmer', 'talent', 'trainer' ]


Sample Input 1

['dream', 'player', 'read', 'write', 'trend']

p

d


Sample Output 2

[ 'player', 'read', 'trend' ]



['dreamer', 'player', 'reader', 'writer', 'trendy']

p

er 

Expected

[ 'dreamer', 'player', 'reader', 'writer' ]

Your Output

[ 'player' ]


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


Please help me.



Speed Typing Test

In this assignment, let's build a Speed Typing Test by applying the concepts we learned till now.

Refer to the below image.

https://assets.ccbp.in/frontend/content/dynamic-webapps/speed-typing-test-output.gif

The Url will show you the required output to be generated.


Instructions:

  • Add HTML container element with id speedTypingTest
  • Add HTML paragraph elements with id timer, quoteDisplay and result
  • Add HTML textarea element with id quoteInput
  • Add HTML button elements with id submitBtn and resetBtn
  • Add the Bootstrap component spinner

By following the above instructions, achieve the given functionality.

  • When the page is opened
  • Make a HTTP request to get a random quotation
  • URL: https://apis.ccbp.in/random-quote
  • Display the random quotation in the HTML paragraph element with id quoteDisplay
  • Start the timer and display the time in seconds in the HTML paragraph element with id timer
  • When a value is entered in the HTML textarea element with id quoteInput and the HTML button element with id submitBtn is clicked
  • If the value entered in the HTML textarea element with id quoteInput is same as the quotation in the HTML paragraph element with id quoteDisplay
  • The timer should be stopped and a success message should be shown in the HTML paragraph element with id result
  • If the value entered in the HTML textarea element with id quoteInput does not match the quotation in the HTML paragraph element with id quoteDisplay
  • The timer should be running and an error message should be shown in the HTML paragraph element with id result
  • When the HTML button with id resetBtn is clicked
  • Make a HTTP request to get a new random quotation
  • Display the new random quotation in the HTML paragraph element with id quoteDisplay
  • Reset the timer to 0 seconds and display the time in seconds in the HTML paragraph element with id timer
  • Empty the HTML textarea element with id quoteInput
  • Add loading status with Bootstrap component spinner while making an HTTP request.

Resources

Clock Image:

  • https://assets.ccbp.in/frontend/dynamic-webapps/clock-img.png


CSS Colors Used:

Background Color Hex Codes Used:

#690cb0

#dac0ff

#f3eaff

#f2ebfe

#ffffff


Border Color Hex Codes Used:

#9aa5b1


Text Color Hex Codes Used:

#690cb0

#3e4c59

#ffffff

#323f4b

  • When the text in the HTML paragraph element with id quoteDisplay and the value entered in HTML textarea element with id quoteInput are not the same, and the HTML button element with id submitBtn is clicked an error message should be shown in the HTML paragraph element with id result


  • Page should consist of HTML textarea element with id quoteInput


  • Page should consist of HTML button element with id resetBtn


  • When the text in the HTML paragraph element with id quoteDisplay and the value entered in HTML textarea element with id quoteInput are not the same, and the HTML button element with id submitBtn is clicked the timer should be running


  • When the text in HTML paragraph element with id quoteDisplay is entered in HTML textarea element, and the HTML button element with id submitBtn is clicked a success message should be shown in HTML paragraph element with id result


  • Page should consist of HTML paragraph element with id timer


  • The HTML paragraph element with id timer should always have numbers greater than or equals to 0


  • Page should be using the Bootstrap component Spinner


  • When the text in HTML paragraph element with id quoteDisplay is entered in HTML textarea element, and the HTML button element with id submitBtn is clicked the timer should stop


  • Paee should consist of HTML paragraph element with id quoteDisplay


  • Page should consist of HTML button element with id submitBtn


  • Page should consist of HTML paragraph element with id result


  • Page should consist of HTML container element with id speedTypingTest


  • JS code implementation should use classList.add and classList.remove to show and hide bootstrap spinner element


  • JS code implementation should use setInterval and clearInterval to implement timer


  • When the reset button is clicked, an HTTP request should be made to get a random quotation from the given URL and the value in the HTML paragraph element with id quoteDisplay should be replaced with quotation received in the response


  • When page is opened, an HTTP request should be made to get a random quotation from the given URL and the HTML paragraph element with id quoteDisplay should have the quotation received in the response.

Book Search

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

Refer to the below image.


https://assets.ccbp.in/frontend/content/dynamic-webapps/book_search_output.gif

Just for not having the image inserting option in this platform, I am giving the url of the image as that we have to generate.


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

By following the above instructions, achieve the given functionality.

  • When a value is entered in the HTML input element with id searchInput and press on Enter key
  • Get title, imageLink, author (HTTP response with key search_results) by making HTTP request using fetch with URL https://apis.ccbp.in/book-store?title=kalam&maxResults=30
  • Set imageLink in the HTML img element and set author in the HTML paragraph element
  • When a value is entered in the HTML input element with id searchInput and an option is selected in the drop down
  • Make a HTTP GET request to fetch the books based on the title entered and maximum number of results
  • If search results not equal to zero, then append the search results to the HTML container element with id searchResults
  • If search results equal to zero, then display "No results found"
  • Add loading status with Bootstrap component spinner while making an HTTP request

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


Rules to be followed:-

  • Page should consist of at least three HTML option elements inside an HTML select element with id selectDisplayCount


  • Page should consist of HTML input element of type search with id searchInput inside an HTML container element


  • Page should be using the Bootstrap component Spinner


  • Page should consist of HTML main heading element


  • Page should consist of HTML container element with id searchResults


  • Page should consist of HTML container element with the CSS property background-image


  • Page should consist of HTML select element with id selectDisplayCount inside an HTML container element


  • When a value is entered in the HTML input element with id searchInput, x books option is selected in the HTML select element with id selectDisplayCount, an HTTP GET request with a valid url parameters title and maxResults should be made


  • When a value is entered in the HTML input element with id searchInput, x books option is selected in the HTML select element with id selectDisplayCount, an HTTP GET request should be made to fetch and display x book items


  • JS implementation should contain addEventListener for keydown event


please Help me.


Filter Unique Characters

Given a string

myString as an input, write a JS program to find the unique characters from the myString.

Quick Tip

You can use the array method indexOf().

Input

  • The input will be a single line containing a string myString

Output

  • The output should be a single line containing an array of unique characters


Sample Input 1

Was it a cat I saw?


Sample Output 1

[

'W', 'a', 's', ' ',

'i', 't', 'c', 'I',

'w', '?'

]


Sample Input 2

I did, did I?


Sample Output 2

[ 'I', ' ', 'd', 'i', ',', '?' ]


the out put should appeared same as shown in sample output's

/* This is a javaScript question, and I will also send the code with function that have to complete :-*/

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


/* complete thefunction */

}

Please help me.


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


This is a javaScript question, and I will also send the code with function that have to complete :-

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

 const subString = readLine();

  

/* complete the function*/

}



LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS