JavaScript Variables var firstnameChristian firstname is as
<html>
<head><title>JavaScript Variables</title>
<script type=\"text/javascript\">
var first_name=\"Christian \";// first_name is assigned a value
var last_name=\"Dobbins \"; // last_name is assigned a value
var age = 8;
var ssn; // Unassigned variable
var job_title=null;
var string=\'\';
string = first_name.concat(last_name , age);
</script>
<script src = \"ex3_6.js\"></script>
</head>
<body bgcolor=\"lightgreen\">
<big>
<p>
<img src=\"Christian.gif\" /></body>
</p>
</big>
</body>
</html>
here is my second file ex3_6.js
document.write(\"<b>Name:</b> \" + string + \"<br />\");
document.write(\"<b>Age:</b> \" + age + \"<br />\");
document.write(\"<b>SSN:</b> \" + ssn + \"<br />\");
document.write(\"<b>Job Title:</b> \" + job_title+\"<br />\");
ssn=\"xxx-xx-xxxx\";
document.write(\"<b>Now SSN is:</b> \" + ssn , \"<br />\");
Use your Java skill to do the following:
a. Keep all var statement but declare a string variable say ‘s’ with initial value of an
empty string;
b. Combine all string into one long string so that in the end
of your program you
only have one “document.write(s)” which will produce the same result as the
textbook example.
c. You may use any picture file for the image.
Solution
<html>
<head><title>JavaScript Variables</title>
<script type=\"text/javascript\">
var first_name=\"Christian \";// first_name is assigned a value
var last_name=\"Dobbins \"; // last_name is assigned a value
var age = 8;
var ssn; // Unassigned variable
var job_title=null;
var string=\' \';
string = first_name.concat(last_name , age);
var s=\' \';
s=first_name.concat(last_name , age , ssn , job_title);
</script>
<script src = \"ex3_6.js\"></script>
</head>
<body bgcolor=\"lightgreen\">
<big>
<p>
<img src=\"Christian.gif\" /></body>
</p>
</big>
</body>
</html>
document.write(\"<b>Textbook:</b> \" + s + \"<br />\");

