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

Question #170001

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}`);

}



1
Expert's answer
2021-03-09T08:03:40-0500
"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 */

    let obj = {
        'area': area,
        'city': city,
        'updatePickupPoint': (newArea, newCity) => {
            obj.area = newArea;
            obj.city = newCity;
        }
    }

    return obj
}

/* 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}`);
}

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