GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Docs
  • Types
  • String

This view

  • Original page
  • New address

GeezerVison is showing arcade.makecode.com — String

Skip to main content
About FAQ Projects GitHub
Reference
sprites controller game music scene info images
Blocks
On Start
Loops
repeat for while for of
Logic
if Boolean
Variables
assign change var var
Math JavaScript blocks Custom blocks
Python
Calling Sequencing Variables Operators Statements Functions Classes
JavaScript
Calling Sequencing Variables Operators Statements Functions Types Classes Interfaces Generics
Types
Number String Boolean Array Function Image Sprite
Blocks Gallery
Miscellaneous
About Support Translate Sharing projects Multiplayer Offline support Save Sign In Cloud Sync VS Code Asset packs
Hardware
Errors Adding New Board Raspberry Pi Makey Makey Shoebox Controller Dev Debug connector
Developers
Command Line Interface Visual Studio Code support Blocks Embed Art, images, colors Sounds
Lessons
Cherry Pickr Barrel Dodger Dance Party BlockOut
Courses
CS Intro 1 CS Intro 2 CS Intro 3

String

A String is a sequence of characters.

A string type is more complex than a number or a boolean. Along with its characters a string type contains information about its length an it lets you change any of its characters using an index. Strings can be broken into smaller strings or added on to make larger strings.

Strings can contain letters, numbers, punctuation marks, and other special characters. Strings can have characters from different languages too.

"abcdefg1234*?!"

A string variable is declared by assigning a variable to a string value:

let myString = "My nice new string is here!"

Strings have operations associated with them so that you can change them or work with parts of them.

let myString = "My nice new string is here!"
// make a smaller string
let mySmallString = myString.substr(0, myString.indexOf("g") + 1)

Create a string variable

let greeting = "hello"

To create a variable that holds a string:

  1. Click Variables (in the Toolbox drawer).
  2. Click on Make a Variable....
  3. Choose a name for your variable, like "greeting", type it in and click Ok.
  4. Drag the new variables block into your code.
  5. Click on the Text (in the Toolbox drawer) and find the " " block.
  6. Click the " " and then type a string like hello.

Your code should look something like this:

let greeting = "hello"

See also

Number

Edit this page on GitHub
Edit template of this page on GitHub
Edit template of this page on GitHub

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.