Query on variable function

var word = ‘alphabet’ ;
var alphabet = ‘word’ ;
print (alphabet) ;
According to grasshopper
Gives word

var y = ‘5’ ;
var x = y ;
print (x) ;
According to grasshopper
Gives 5

I didn’t understand the difference.

Hey there,

It might help to go through the code line by line.

In the first example, the variable word stores a string with the text 'alphabet'. The variable alphabet stores a string with the text 'word'.

Then the print() function is called with the variable alphabet as an argument. This variable stores the string 'word', so the text 'word' is printed.

In the second example, y is declared with the value 5.
Then, x is declared and given the value y. Because y has the value 5, x now also has the value 5.

Hope this helps!
Ben