JSFiddle - React, Tailwind, and code Playground

by Brian Scaturro

CSS

h1 {
    margin:25px 0;
}

p {
    margin:5px 0;
}

JavaScript

/**********************************************
 * JavaScript primitive types
 **********************************************/

/**
 * Strings
 */
writeTo('h1', 'Strings');
writeLn('This thing inside of this writeLn thing is a string');
writeLn("A string can be used with double or single quotes");
writeLn("It is really a matter of what you're intentions are for the type of quote");
writeLn('As someone once said - "Internet quotes are always true"');
writeLn("We can read our strings\
         a little better if we put\
         a backslash at the end of\
         each line.");
console.log('html handles new lines a little differently, but the console uses\nescape sequences like "backslash n"');
writeLn('Strings can have escape sequences - that is a backslash followed by an identifier');
writeLn('We can do all sorts of fun things with this, like unicode');
writeLn('You may call me \u305B\u3093\u305B\u3044');
writeLn('We can concatenate,' + ' or join together,' + ' multiple strings with the "+" operator.');
writeLn('Strings have a type of - ', typeof('what am i?'));

/**
 * Numbers
 */
writeTo('h1', 'Numbers');
writeLn('An integer is a ', typeof(3));
writeLn('A floating point number is a ', typeof(3.5));
writeLn('A hex value is also a ', typeof(0xAD));

//Floating point numbers can be represented in several ways
writeLn(3.295, ', ', .33333333333, ', ', 3.54e23, ', ', 1.785432E-26);

writeTo('h2', 'Arithmetic in JavaScript');
writeLn('2 + 2 = ', 2 + 2);
writeLn('5.9 - 2.5 = ', 5.9 - 2.5);
writeLn('3 * 3 = ', 3 * 3);
writeLn('14 / 7 = ', 14 / 7);

/**
 * Boolean values
 */
writeTo('h1', 'Boolean values');

//Booleans represent what is true or false, what is on or off, what is yes or no
writeLn(true, ' is of type ', typeof(true));
writeLn(false, ' is of type ', typeof(false));

//We can negate the value of a boolean using the '!' operator
writeLn(!true);
writeLn(!false);

//Boolean values are generally the result of logical expressions and comparisons such as ==, >, <,...