what does string.length show/ mean
number of characters , including spaces in the data in the variable has
what does string.substring show/ mean
(the starting position, number of characters)
what would the code
someText = “Computer Science”
print(someText.substring(3,3))
print out?
put
what is a string
an object that represents a sequence of characters
what would be printing out with : myString.substring(5,10)
if myString = “Samsung exploding galaxies”
ng ex
what does temp.substring(j,1) mean
extracts a single character from the word starting at position j so that each character can be stored individually in the 2D display array
The algorithm will make use of a function, contains, that compares two strings and checks
if the second string contains the first string. For example, calling the function with (“fox”,
“foxhound”) this would return true.
The function needs to:
* Take two strings as parameters, string1 and string2
* return true if string1 is contained within string2, or both strings are identical
* return false if string1 is not contained within string2
Write, using pseudocode, the function contains.
function contains(string1, string2)
wordInside = false
for i = 0 to (string2.length – string1.length)
if string2.substring(i, string1.length) ==
string1 then
wordInside=true
endif
next i
return wordInside
endfunction
how to get a string length
using the variable stringname
stringname.length
how to get a substring using the variable name stringname
stringname.subString(startingPosition, numberOfCharacters)