JSFiddle - React, Tailwind, and code Playground

JavaScript

// Create a person object
var recipe = {
    "name": "Buffalo Chicken Dip",
    "prep_time": "2 hours",
    "servings": 12,
    "ingredients": ["Chicken", "Ranch Dressing", "Buffalo Sauce", "Cream Cheese"],
    
    "listIngredients": function(){
        
        var list = "";
        
        // Step through each item in this recipe's ingredients array
        for(var i = 0; i < this.ingredients.length; i++){
            
            list += this.ingredients[i];
            
            // if it isn't the last item, add a comma
            if(i != (this.ingredients.length-1)){
                 list += ", ";   
            }
        }
        
        alert(list);
        
    }
};

// call our listIngredients function
recipe.listIngredients();