Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
April 3rd, 2013, 09:56 AM
 petar22
Registered User

Join Date: Apr 2013
Posts: 1
Time spent in forums: 2 m 18 sec
Reputation Power: 0

javascript:

Explain the following JavaScript code. What will the output be?

var multipleValues = [50, 80, 100];
console.log (multipleValues.length);
var len = multipleValues.length;
for (x=0; x < len; x++)
{console.log(multipleValues[x]);}
var reverseValues = multipleValues.reverse();
var rlen = reverseValues.length;
for (x=0; x < rlen; x++)
{console.log(reverseValues[x]);}

------------------------------------------------------------------------------------------

Explain the following JavaScript code. What will the output be?

var valueOne = "15";
var valueTwo = "30";
var vo = vt = 0;

vo = parseInt(valueOne);
vt = parseInt(valueTwo);

document.writeln("<p>The first number is " + vo + ", the second is "
+ vt + ".</p>");

var result1 = valueOne + valueTwo;
document.writeln("<p>The value for result1 is "
+ result1 + "</p>");

result2 = vo + vt;
document.writeln("<p> The value for result2 is " +
result2 + "</p>");

#2
April 3rd, 2013, 10:38 AM
 Jacques1
You have been warned

Join Date: Jul 2012
Posts: 3,154
Time spent in forums: 2 Months 3 Weeks 6 Days 11 h 30 m 32 sec
Reputation Power: 1092
Hi,

this is no homework forum. We can help you with concrete questions and problems, but we're not here do your work.

And this is actually something you can do yourself, even if you've been sleeping through the whole class. Grab a text editor (Notepad will do), create an HTML file, paste the JavaScript and open it in your browser. If you replace console.log() with alert(), you don't even need to create a file:

http://jsfiddle.net/

 Viewing: Dev Shed Forums > Web Design > JavaScript Development > Answer to the questions ( JavaScript) , please