View Single Post
Old 01-29-2013, 01:01 AM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,579
Thanks: 62
Thanked 4,064 Times in 4,033 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Doesn't happen for me.

I changed your alert() to document.write() and I get this output:
Code:
0 - menos de 10 min
1 - 1/2 hora
2 - 1 hora
3 - 1 hora y media
4 - 2 horas
5 - 2 horas y media
6 - 3 horas
7 - 3 horas y media
8 - 4 horas
9 - 4 horas y media
10 - 5 horas
What browser are you using?

I should note that normally we would not use for (item in losTiempos) for an indexed array like that.

And the array can be created more simply, as well:
Code:
<script type="text/javascript">
var losTiempos= [
    "menos de 10 min",
    "1/2 hora",
    "1 hora",
    "1 hora y media",
    "2 horas",
    "2 horas y media",
    "3 horas",
    "3 horas y media",
    "4 horas",
    "4 horas y media",
    "5 horas"
  ];
for (var i = 0; i < losTiempos.length; ++i )
{
    document.write(i + " - "+losTiempos[i] + "<br/>");
}
</script>
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Users who have thanked Old Pedant for this post:
juliushg (01-29-2013)