This is down to changes that were made for new versions of ZPE.
a single quotation mark or
' (or apostrophe) or double quotation marks or
" (speech marks).
The following example stores a string in a variable:
var x = "Hello"; var y = 'World';
This part of the tutorial will focus on manipulation of strings.
A string containing a substring can have that substring inside it replaced
var s = "Hello world"; s = s.replace("world", "everyone"); alert(s);
length property of the string.
Other languages such as PHP use a function to obtain the length of string. The following is an example of
var s = "Hello world"; var length = s.length; alert(length);
To get the index or position of a substring within another string can be found using the
var s = "Hello world"; var position = s.indexOf("world"); alert(position);
It is possible to cut a section of a string or substring from a string using the
var s = "Hello world"; var sub_string = s.substr(6, 5); alert(sub_string);
substr method takes two arguments, the first is the start index and the second is the
length of the substring:
var s = "Hello world"; var sub_string = s.substr(0, 5); alert(sub_string);
var str1 = "Hello"; var str2 = "world"; var concatenated = str1 + str2; alert(concatenated);
Since the plus operator also works with mathematics, the following will parse the mathematics and will not concatenate:
var str1 = 5; var str2 = 10; var concatenated = str1 + str2; alert(concatenated);
It can be concatenated by converting it to a string first. This is achieved by concatenating an empty string ("") at the beginning of the concatenation:
var str1 = 5; var str2 = 10; var concatenated = "" + str1 + str2; alert(concatenated);
Strings are, as mentioned before, an ordered set of characters. As such, strings are arrays. This means that the standard method of obtaining an element from within the string can be used. This will return the appropriate character at that position:
var s = "Hello world"; var character = s; alert(character);
S1s and S2s really enjoyed the lesson on cybercrime using the lesson on How to Rob A Bank on… https://t.co/MxjDYE2JFu
7 months ago
S2s doing really well in hardware test! Also really enjoying doing tests electronically rather than on paper.… https://t.co/ritdfcW6Mw
7 months ago
S1 and S2 pupils listing input and output devices and giving answers such as keyboard and mouse but there were also… https://t.co/dGxDkYqFxo
7 months ago