Answer to Question #171789 in HTML/JavaScript Web Application for hemanth

Question #171789

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


1
Expert's answer
2021-03-16T03:45:03-0400
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());
}

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS