Trekking Kit
function Trekking(kit, item) {
this.kit = kit;
this.item = item;
}
function main() {
const item = readLine();
const trekkingKit = {
ruckSackBag : true,
clothes: ["Shirt", "T-Shirt/Full sleeves","Jeans"],
firstAid: true,
waterBottle: "2 liters",
sunGlasses: "UV Protection",
headTorch: true,
medicines: true,
footWear: "Non-skid",
food: ["dry fruits", "nuts", "chocolate bars"]
};
/* Write your code here */
}
Sample Input 1
ruckSackBag
Sample Output 1
true
Sample Input 2
surfboard
Sample Output 2
false
i want code in between write code here
function Trekking(kit, item) {
this.kit = kit;
this.item = item;
}
function main() {
const item = readLine();
const trekkingKit = {
ruckSackBag : true,
clothes: ["Shirt", "T-Shirt/Full sleeves","Jeans"],
firstAid: true,
waterBottle: "2 liters",
sunGlasses: "UV Protection",
headTorch: true,
medicines: true,
footWear: "Non-skid",
food: ["dry fruits", "nuts", "chocolate bars"]
};
/* Write your code here */
Trekking.prototype.isTrekking = function() {
return Object.getOwnPropertyNames(this.kit).some( item => item === this.item )
}
const itemInKit = new Trekking(trekkingKit, item);
console.log(itemInKit.isTrekking());
}
Comments
Leave a comment