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

Given a constructor function ArithmeticOperations in the prefilled code and two numbers firstNumber and secondNumber as inputs, add the following methods to the constructor function using the prototype.


Square at Alternate Indices

Given an array

myArray of numbers, write a function to square the alternate numbers of the myArray, starting from index 0 using the array method map.Input

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

Output

  • The output should be a single line containing an array with alternate numbers squared

Constraints

  • Each value in the array must be a number

Sample Input 1

[ 1, 2, 3, 4, 5 ]

Sample Output 1

[ 1, 2, 9, 4, 25 ]

Sample Input 2

[ 2, 4 ]

Sample Output 2

[ 4, 4 ]




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




String Ending with Vowel

Given an array of vowels in the prefilled code and a string

inputString as an input, write a JS program to check whether the inputString ends with a vowel.

Quick Tip

You can use the string methods toUpperCase() and endsWith().

Input

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

Output

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

Sample Input 1

Five

Sample Output 1

true

Sample Input 2

Apples grow best where there is cold in winter

Sample Output 2

false




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





  1. 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
  1. For cleaning the garden,
  • resolve with "Garden Cleaned" text
  1. 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

Output

  • The output should be a string with the appropriate messages in separate lines

Sample Input 1

true

true

Sample Output 1

Grass Trimmed

Garden Cleaned

Watered Plants

Sample Input 2

true

false

Sample Output 2





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 itemreject with "Category Not Found" text, if the

categoryOfItem does not match with any catergory in the martreject 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

itemOutput

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




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"




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




LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS