Create a javascript variables greeting


Discuss the below:

Q: Suppose the Javascript variables greeting and name have been declared as follows:

var greeting;
var name;

(a) Complete the table below to show the values of the variables after each line of the following code has been executed:

1. greeting = 'Hello';
2. name = 'Earthling';
3. greeting = greeting + name;

after line1: greeting: name
after line2: greeting: name
after line3: greeting: name

(b) Write a line of code to replace line 3 above which will create a greeting 'Hello Earthling!' with a space in between 'Hello' and 'Earthling' and an exclamation mark at the end.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Create a javascript variables greeting
Reference No:- TGS01938168

Now Priced at $20 (50% Discount)

Recommended (96%)

Rated (4.8/5)