I am trying to call an array reference using the name of different array:
My alert keeps coming up as undefined. I'm not sure what Im missing here. I am expecting to see a result of "Water1"
var Water2 = new Object();
Water2.Name = 'Water2';
Water2.Level = '1';
Water2.Common = 'Water1';
Water2.CanBuild = 'no';
Water2.CanWalk = 'no';
Water2.SpawnChance = '5';
$(".cube").each(function(index) {
var thiscubetype = $(this).attr('class').split(' ')[1];
var nextcubetype = $(this).next().attr('class').split(' ')[1];
var nextcommon = nextcubetype.Common;
console.log(nextcommon);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="cube Water1"></div>
<div class="cube Water2"></div>