Skip to content

String

A string is a data type for storing text.


Syntax

To create a new string:

1
var animal = "Bear";

To change an existing string:

1
animal = "Lion";

To delete a string:

1
delete animal;

Modulo1 has no preference for double quotes or single quotes, so long as you use the same kind of quotes at the beginning and end of the string. For example, this is achieves the exact same result:

1
animal = 'Lion';

To create a duplicate of a string:

1
var mammal = animal;

If you need to include one or more single quotes within a string:

1
var fact = "There's nothing wrong with pineapple on pizza!";

Properties

A property is a special feature of a variable that can be used to get and/or set some aspect of that variable.

length

The length property can be used to find out how many letters exist within a particular string variable

1
var result = fact.length;

value

The value property can be used to find out the value stored within a particular string variable

1
var result = fact.value;

type

The type property can be used to find out the data-type of a particular string variable. The result will always be "string"

1
var result = fact.type;

Functions

print( null x )
print( number x )
print( boolean x )
print( array x )
print( object x )
print( iterator x )
print( melody x )
print( drumRiff x )
print( function x )
print( class_object x )

The print function prints a string representation of any variable to the Modulo1 output

1
print(myVariable);