String Manipulation Flashcards
Card 1 of 7
All 7 cards in this deck
In OCR Exam Reference Language, how do you join two strings together?
e.g. join
firstNameandsurnamewith a space between themWith the
+operator (concatenation).fullName = firstName + " " + surnameHow do you find the number of characters in a string?
e.g.
word = "computer"word.length— this gives8.What does
.substring(x , i)return?e.g.
subject = "computer",subject.substring(3,5)icharacters starting at indexx, where indexes start at 0 — returns"puter".What do
.left(i)and.right(i)return?e.g.
word = "computer", thenword.left(3)andword.right(2).left(i)gives the firsticharacters and.right(i)the lasticharacters —"com"and"er".What do
.upperand.lowerdo?e.g.
"Cat".upper.upperconverts every letter of the string to uppercase and.lowerconverts every letter to lowercase — gives"CAT".What do
ASC()andCHR()do?e.g. given that the character code for
"A"is 65:ASC("A")andCHR(66)ASC()returns the character code of a character andCHR()returns the character for a code —65and"B".True or false? Spaces and punctuation are counted by
.lengthwhen finding the number of characters in a string.True.
.lengthcounts every character in the string, including spaces and punctuation.