+ 1

Create a Javascript restaurant class with following properties :-

1.restaurant list :- this will contain a list of restaurant object with restaurant name ,address and city 2.print all restaurants name : this will print all restaurants name in console. Below is my code plss help me. https://code.sololearn.com/WqbbLjo1vQHZ/?ref=app

23rd Mar 2021, 7:50 AM
Dev Looper
Dev Looper - avatar
19 ответов
+ 3
I read your code. But I'm not clear whether you're supposed to have one Restaurant class and a RestaurantList class (as a collection of Restaurant object)? Maybe I can understand better if you post the complete task Description. Do you have it?
23rd Mar 2021, 3:57 PM
Ipang
+ 3
Prashant Singh I wrote this last night and added a bit of update on it after I see Martin's note for your duplicate thread. This is in vanilla JS as an alternative to Martin's solution in Node. https://code.sololearn.com/W5Kes8D3Fq87/?ref=app
24th Mar 2021, 6:36 AM
Ipang
+ 2
Do you want the Restaurant class to be separated from the RestaurantList class? or should the Restaurant class contain a list of its own?
23rd Mar 2021, 9:14 AM
Ipang
+ 2
Martin, Thank you for the suggestion. TBH I am still on the grey area about designs, that is, I'm not certain which I should follow amongst the many. Not too sure whether it's my English or what, but the pages I've read this far still doesn't help me find a firm ground. I guess for this one, I'm just following the task Description, which said to print into console, without a further detail on implementation preference.
24th Mar 2021, 2:13 PM
Ipang
+ 1
Martin Taylor thanks ! I understand the concept now.Thank you.
24th Mar 2021, 5:02 AM
Dev Looper
Dev Looper - avatar
+ 1
Ipang only one class that is restaurant class ....in which we have to store array of objects and access them by restaurantlits name. The question have full description sir.
24th Mar 2021, 5:04 AM
Dev Looper
Dev Looper - avatar
+ 1
Ipang great sir ! I get the concept after Martin Taylor sir code , But I am learning javascript and unaware of vanilla js. Thankyou for coding for me .I appreciate it.
24th Mar 2021, 8:55 AM
Dev Looper
Dev Looper - avatar
+ 1
Prashant Singh You're welcome 👌 And I correct myself, I said it was written in vanilla js, but it contains bits of ES6 code (a standardized Javascript IIRC).
24th Mar 2021, 9:08 AM
Ipang
+ 1
Martin, I've read a bit about MVC, would that be seamlessly feasible in Code Playground though? Let me try to add that getter in now ...
24th Mar 2021, 3:16 PM
Ipang
+ 1
Martin, I've added a `get` method But I'm not sure why, because it worked even without the `get` method.
24th Mar 2021, 3:56 PM
Ipang
0
Ipang I need to make a class restaurant or object in which I have to add name city and address...and I need to print all the city in console.
23rd Mar 2021, 3:45 PM
Dev Looper
Dev Looper - avatar