JSFiddle - React, Tailwind, and code Playground
by LeeMellinger
JavaScript
// Do
var count = 10;
do
{
document.write(count + "<br>");
count--;
}while(count > 5);
document.write("<br> ---------------- <br>");
// While
count = 10;
while(count > 0)
{
document.write(count + "<br>");
count--
}
document.write("<br> ---------------- <br>");
// For
var a = new Array("a", "b", "c");
for(i in a)
{
document.write(a[i] + "<br>");
}
document.write("<br> ---------------- <br>");
document.write("test1 <br>")
document.write("test2 <br>")
var firstName = "Lee";
var lastName = "Mellinger";
document.write(firstName + "." + lastName + "<br>")
var initials = firstName.substring(0, 1) + lastName.substring(0, 1);
document.write(initials + "<br>")
document.write((5 > 10) ? "5 > 10" : "5 < 10" + "<br>");
var x = 5;
var y = 5;
if (x > y)
{
document.write("x > y" + "<br>");
}
else if (x < y)
{
document.write("x < y" + "<br>");
}
else
{
document.write("x = y" + "<br>");
}