Listings 13.01 and 13.02 - Loading JavaScript with a script tag
JS Bin
HTML:
<script src="http://output.jsbin.com/qezoce.js"></script>
JS:
var num = between(3, 7);
console.log(num);
Listings 13.01 and 13.02 - Loading JavaScript with a script tag - Tasks 2 & 3
- Create a rectangle object with random length and width properties each between 1 and 10 units long.
- Define a showArea function that accepts a rectangle as an argument and logs its area to the console.
var rect = {
length: between(1, 10),
width: between(1, 10)
};
var showArea = function (rect) {
var info = "A " + rect.length + " by " + rect.width;
info += " rectangle has area " + rect.length * rect.width;
console.log(info);
};
showArea();