Skip to content

Instantly share code, notes, and snippets.

@ndonolli
Forked from anonymous/index.html
Last active June 26, 2016 20:01
Show Gist options
  • Save ndonolli/03189331eb80c49af909c4400f798548 to your computer and use it in GitHub Desktop.
Save ndonolli/03189331eb80c49af909c4400f798548 to your computer and use it in GitHub Desktop.
JS Bin// source https://jsbin.com/pobicay
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
/*
===================
STRING MANIPULATION
===================
It's vital to be able to manipulate strings because they can hold important user data or information. Javascript gives us several tools and techniques to do this.
*/
var pizza = 'pizza';
// As we know, we can concatenate strings using the ( + ) operator.
var pizzazz = 'pizzazz';
console.log(pizza + pizzazz);
// > "pizzapizzazz"
// With strings, we can also refer to individual characters using bracket notation. Pretty cool!
console.log(pizza[2]);
// > "z"
/*
Strings can have properties and methods too since String is a native object within javascript. Even though strings are a primitive datatype, we can use these methods for manipulation.
*/
// For instance, we can determine the length of a string:
var string = 'Beetlejuice';
console.log(string.length);
// > 5
// Or make it uppercase:
console.log(string.toUpperCase());
// > "BEETLEJUICE"
// We can also use the ( \n ) escape character to indicate a new line. This will be ignored in the output of the string.
string = 'Beetlejuice\nBeetlejuice\nBeetlejuice';
console.log(string);
// > "Beetlejuice
// Beetlejuice
// Beetlejuice"
</script>
<script id="jsbin-source-javascript" type="text/javascript">/*
===================
STRING MANIPULATION
===================
It's vital to be able to manipulate strings because they can hold important user data or information. Javascript gives us several tools and techniques to do this.
*/
var pizza = 'pizza';
// As we know, we can concatenate strings using the ( + ) operator.
var pizzazz = 'pizzazz';
console.log(pizza + pizzazz);
// > "pizzapizzazz"
// With strings, we can also refer to individual characters using bracket notation. Pretty cool!
console.log(pizza[2]);
// > "z"
/*
Strings can have properties and methods too since String is a native object within javascript. Even though strings are a primitive datatype, we can use these methods for manipulation.
*/
// For instance, we can determine the length of a string:
var string = 'Beetlejuice';
console.log(string.length);
// > 5
// Or make it uppercase:
console.log(string.toUpperCase());
// > "BEETLEJUICE"
// We can also use the ( \n ) escape character to indicate a new line. This will be ignored in the output of the string.
string = 'Beetlejuice\nBeetlejuice\nBeetlejuice';
console.log(string);
// > "Beetlejuice
// Beetlejuice
// Beetlejuice"</script></body>
</html>
/*
===================
STRING MANIPULATION
===================
It's vital to be able to manipulate strings because they can hold important user data or
information. Javascript gives us several tools and techniques to do this.
*/
var pizza = 'pizza';
// As we know, we can concatenate strings using the ( + ) operator.
var pizzazz = 'pizzazz';
console.log(pizza + pizzazz);
// > "pizzapizzazz"
// With strings, we can also refer to individual characters using bracket notation.
// Pretty cool!
console.log(pizza[2]);
// > "z"
/*
Strings can have properties and methods too since String is a native object within
javascript. Even though strings are a primitive datatype, we can use these methods
for manipulation.
*/
// For instance, we can determine the length of a string:
var string = 'Beetlejuice';
console.log(string.length);
// > 11
// Or make it uppercase:
console.log(string.toUpperCase());
// > "BEETLEJUICE"
// We can also use the ( \n ) escape character to indicate a new line. This will be
// ignored in the output of the string.
string = 'Beetlejuice\nBeetlejuice\nBeetlejuice';
console.log(string);
// > "Beetlejuice
// Beetlejuice
// Beetlejuice"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment