Request Dev Services ยป

How to begin toying and learning JavaScript (Intro JS tips)

So, this article is a basic introductory run down of using JavaScript to create simple variables, access them, and what document.write is. For the simplicity of this illustration, it is all condensed in one HTML file and passed between inline script tags.

Note: The <script> tags can be OK to start with, but as you and the project progresses, the best practice and way to go is have all your JavaScript in a separate external .js file, called right above the closing </body> tag.

<!DOCTYPE html>
<title>Basic JavaScript Tips</title>

<script src="./modernizr.custom.05819.js"></script>

//initialize variables for service names and speeds
var servicelName = "Basic";
var service2Name = "Express";
var service3Name = "Extreme";
var service4Name = "Ultimate";
var servicel5peed = 5;
var service25peed = 25;
var service35peed = 50;
var service4Speed = 150;

<h2>Simple variable usage</h2>
    <th>Download speed (Mbps)</th>

// create ordered list
document.write("<h2>What does <i>document.write</i> do?</h2>");

document.write("<li>Reduce spending on non- necessities.</li>");
document.write("<li>Use extra money to pay off debt, starting with highest-interest credit card.</li>");
document.write("<li>Continue paying off debts until you are 8 debt free.</li>"); document.write("<li>Put a fixed percent of your pay aside in savings every payday.</li>");


Live Demo of the above code ran in the simple online JavaScript IDE, Jsfiddle (a great intro free online JS IDE for testing small scripts).

About the Author
Cameron Cashwell Web Developer
I build websites, web apps, and software. Wanna work together? Let's chat about your project!

Leave a Reply

Notify of