Q:

Removing a row from a javascript dataset and carrying it over into another dataset?

Essentially, I have 2 datasets and a function. (The numbers after the name are stats, and are just placeholder but I need them to carry over exactly)
var randomIngredientsList = [["Bread", 1, 2], ["Water", 5, 2]]
var ingredients = [["Mustard", 2, 3]]

When I'm supposed to get a random ingredient, I want to carry over from randomIngredientsList, remove that specific part, and put it into ingredients.
There will also be different randomIngredientsLists with different tiers and stats so i need it to be able to differentiate them.
My function now looks something like this:
function generateRandomIngredient(nameOfArray){ 
        var randomValue = Math.floor(Math.random() * nameOfArray.length) //grabs a random number from 0-the length of the dataset
        console.log(randomValue)
            if(nameOfArray.length = 0){     // if ingredient  list is empty
            exploreLogger.unshift("You seem to have picked clean all the ingredients in this tier. Good job!"); //explorelogger is a log at the end of the screen, which shows events
            } else { //if it's not empty
    ingredients.push(nameOfArray[randomValue]) // add it to the ingredients list
    nameOfArray.splice(randomValue, 1) //remove the row from the dataset
            }
}

When it run it with generateRandomIngredient(randomIngredientsList) it deletes all objects in randomIngredientsList and adds an undefined value to ingredients. I don't know what to do, I've spent 2 hours on this issue and found nothing about it online. Thanks to anyone who provides any help or answers.

A:

You are assigning 0 to the array's length instead of comparing.
if(nameOfArray.length = 0){  

should be changed to
if(nameOfArray.length === 0)

