JSFiddle - React, Tailwind, and code Playground

by JCatJ098d9837

JavaScript

var birds = new Array();
	birds['cardinal'] = "Red";
	birds['jay'] = "Blue";
	birds['goldfinch'] = "Yellow";	
	birds['Raven'] = "Black";
	birds['parrot'] = "Green";
	
	document.write("Print Original<br /><br />");
	
	document.write("Just the colors:" + "<br />");
	
	for (var i in birds)
	{
		document.write(birds[i] + "<br />");
	}
	
	document.write("<br />");
	document.write("<br />");
	
		document.write("The colors AND bird names, associative array: " + "<br />");
	
	for (var i in birds)
	{
		document.write(birds[i] + ": "  + i + "<br />");
	}
	
	document.write("<br /><br />" + "Now push birds into birdColor:" + "<br /><br />")
	
	var birdColor = new Array();
	
	for(var i in birds)
	{
	birdColor.push(birds[i]);
	}
	
	document.write("<br />");
	document.write("<br />");
	
	birdColor.sort();
	for(var i in birdColor)
	{
		document.write(i + " " + birdColor[i] + "<br />");
	}