THIS IS MY HTML CODE:-
<button type="button" onclick="printAllRestaurantByName()">printAllRestaurantByName</button><br></br>
THIS IS MY JAVASCRIPT CODE:-
<pre lang="Javascript"><pre> class restaurantManager{
restaurantList = [
{name:"Barbeque Nation",address:"varanasi",city:"varansi"},
{name:"The Table",address:"varnasi",city:"varansi"},
{name:"i love my wife",address:"varansi",city:"varansi"},
{name:"Batti chokha",address:"varansi",city:"varansi"}
]
printAllRestaurantByName = () =>{
for(let i=0;i>this.restaurantList.length;i++){
console.log(this.restaurantList[i].name)}}}}
AFTER EXECUTING THIS I AM GETTING THE FOLLOWING ERRROR:
Uncaught ReferenceError: printAllRestaurantByName is not defined
at HTMLButtonElement.onclick
GUYS PLEASE HELP!!!!!!
What I have tried:
class restaurantManager{
restaurantList = [
{name:"Barbeque Nation",address:"varanasi",city:"varansi"},
{name:"The Table",address:"varnasi",city:"varansi"},
{name:"i love my wife",address:"varansi",city:"varansi"},
{name:"Batti chokha",address:"varansi",city:"varansi"}
]
constructor(){
restaurantList.foreach(printAllRestaurantByName = () =>{
for(let i=0;i>this.restaurantList.length;i++){
console.log(this.restaurantList[i].name)}})}}