Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- alert('hello world');
- console.error('this is an error');
- console.warn('this is a warning');
- console.log('Hello world');
- // Variables: var, let and, const. Mainly use let and const
- // as var is a global variable
- let age = 30;
- age = 35;
- console.log('My age is ' + age);
- // Use const unless you know you'll be reassigning something, like a score.
- //Data Types: Strings, numbers, boolean, null, undefined, symbol
- const name = 'Jason';
- const myAge = 41;
- const isCool = true;
- const rating = 4.5;
- const x = null; // this means it's empty, a variable with nothing in it
- const y = undefined;
- let z; //this is also undefined.
- console.log(typeof name);
- console.log(typeof myAge);
- console.log(typeof isCool);
- console.log(typeof rating);
- console.log(typeof x);
- console.log(typeof y);
- console.log(typeof z);
- //Concatenation
- console.log('My name is ' + name + ' and I am ' + age);
- //Template... uses backticks, not single quotes
- const hello = (`My name is ${name} and I am ${age}`);
- console.log(hello);
- const s = 'Hello World!';
- console.log(s.length);
- console.log(s.toUpperCase()); //makes s uppercase
- console.log(s.toLowerCase());
- console.log(s.substring(0,5).toUpperCase()); // only prints first five letters
- const t = 'tech, computers, it, code'
- console.log(t.split(', ')); //splits t into an array
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement