+ 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
11 Respuestas
+ 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?
+ 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
+ 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?
+ 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.
+ 1
Martin Taylor thanks ! I understand the concept now.Thank you.
+ 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.
+ 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.
+ 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).
+ 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 ...
+ 1
Martin,
I've added a `get` method
But I'm not sure why, because it worked even without the `get` method.
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.