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.
The input will be a single line containing a string
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
In this assignment, let's build a Articles Page by applying the concepts we learned till now. You can use the Bootstrap concepts and CCBP UI Kit as well.
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
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
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().
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
Sample Input
[ 12, 2, 2, 4, 1 ]
Sample Output
616 -14 -14 112 -77
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().
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.
The input will be a single line containing a string
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