First Question -- I am running through a 2 dimensional array, and in the array I am adding an image to img sources in the body based on whether the array reads as true or false.
My question is concerning an example I found that runs through the row and column to check whether it is true or false, and it reads as:
document.getElementById("imagename" + (i * imagetruefalse.length + j)).src = "true.png";
WHY is it using the * to run through the array? I'm trying to figure out why it's using that operator to run through and [j] but I just can't figure it out.
Second Question: I've noticed in some examples of arrays people use +arrayname+ to speak back to it -- why put the array name through the + signs? I can't find an explanation on this. For example:
the -- document.write("<b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"</b>") -- part of the following example.
<script type="text/javascript">
var mydate=new Date()
var year=mydate.getFullYear()
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
//if the current date is less than 10, pad it.
if (daym<10)
daym="0"+daym
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
//write out the final results
document.write("<b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"</b>")
</script>
All insight is greatly appreciated!
My question is concerning an example I found that runs through the row and column to check whether it is true or false, and it reads as:
document.getElementById("imagename" + (i * imagetruefalse.length + j)).src = "true.png";
WHY is it using the * to run through the array? I'm trying to figure out why it's using that operator to run through and [j] but I just can't figure it out.
Second Question: I've noticed in some examples of arrays people use +arrayname+ to speak back to it -- why put the array name through the + signs? I can't find an explanation on this. For example:
the -- document.write("<b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"</b>") -- part of the following example.
<script type="text/javascript">
var mydate=new Date()
var year=mydate.getFullYear()
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
//if the current date is less than 10, pad it.
if (daym<10)
daym="0"+daym
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
//write out the final results
document.write("<b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"</b>")
</script>
All insight is greatly appreciated!