Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions lesson07/basicPrototype.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>String Object</title>
<script type="text/javascript">
function blueVerdandaFont(){
return '<span style="font-face: verdana; color: blue; font-size: 30px;">' + this.toString() + '</span>';
}
String.prototype.blueV =blueVerdandaFont;
String.prototype.blueVDescription = 'The blueV() function creates blue Verdana font.';
</script>
</head>
<body>
<h2>CIW JavaScript Specialist</h2>
<h3>String Object</h3>
<script>
var fifthString = 'This is the fifth string which is good';
document.write('<p>' + fifthString.blueVDescription + '</p>');
document.write('<p>' + fifthString.blueV() + '</p>');
document.write('indexOf("h",20) for fifthString is ' +
fifthString.indexOf('h',20) + '<br/>');
document.write('lastIndexOf("is",20) for fifthString is ' +
fifthString.lastIndexOf("is",20) + '<br/>');
document.write(fifthString.substring(3,9)+'<br/>');
document.write(fifthString.substr(3,7)+'<br/>');
document.write('charAt(8) is '+fifthString.charAt(8) +
'<br/>');
</script>
</body>
</html>
38 changes: 38 additions & 0 deletions lesson07/basicStringObject.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>String Object</title>
<script type="text/javascript">
</script>
</head>
<body>
<h2>CIW JavaScript Specialist</h2>
<h3>String Object</h3>
<script type="text/javascript">
//define string variable and assign string with single quote
var firstString = 'This is the first string<br/>';
var secondString = 'This is the second string<br/>';
//use string method
document.writeln(firstString.bold()); //document.writeln make new line
document.writeln(secondString.big()); //big method makes text big
document.write('Broward College'.link('https://broward.edu') + '<br/>'); //add link, wrap text
document.write('Broward College'.toUpperCase() + '<br/>');
document.writeln('Broward College'.fontcolor('red') + '<br/>'); //also can use hexadecimal
var thirdString = 'Javascript';
for (var i = 0; i < thirdString.length; i++) {
document.write(thirdString[i]+'<br/>'); //access each character of string and display with newLine
};
var fourthString = 'c:\\windows\\system32';
document.write(fourthString + '<br/>');
var fifthString = 'This is the fifth string which is good';
document.write(fifthString.italics().bold() + '<br/>');
document.write('indexOf("h",20) for fifthString is ' +
fifthString.indexOf("h",20) + '<br/>');
document.write('lastIndexOf("is",20) for fifthString is ' +
fifthString.lastIndexOf("is",20) + '<br/>');
document.write(fifthString.substring(3,9)+'<br/>');
document.write(fifthString.substr(3,7)+'<br/>');
</script>
</body>
</html>
54 changes: 54 additions & 0 deletions lesson07/example3a-pgc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Arrays</title>
</head>
<body>
<h2>CIW JavaScript Specialist</h2>
<h3>Arrays</h3>
<script type="text/javascript">
/*JS is allows prototyping where properties and methods can be added to a standard object
if a property or method to display a string in certain way added, we would use prototype*/
var question = new Array(10);
question[0] = 'What is 5 * 6?';
question[1] = 'Who played Scarlett O\'Hara?';
question[2] = 'Which horse won the 1980 Irish Derby?';
var answers = new Array(30,'Vivien Leigh','Tyrnavos');
for (var i in question) {
document.write('Q: ' + question[i] + ' A: ' + answers[i] + '<br/>');
}
var myArray = new Array('Value 2','Value 1','Value 3',
'Value 11','Value 5','Value 4');
document.write(myArray + '<br/>');
myArray.reverse();
document.write(myArray + '<br/>');
myArray.sort();
document.write(myArray + '<br/>');
var myNumbers = new Array(4,6,1,3,9,11,2,5);
myNumbers.sort();
document.write(myNumbers + '<br/>');
var myManyArrays = myNumbers.join('::');
document.write(myManyArrays + '<br/>');
myNumbers.push(21);
document.write(myNumbers + '<br/>');
var poppedNumber = myNumbers.pop();
document.write(myNumbers + '<br/>');
myNumbers.unshift(21);
document.write(myNumbers + '<br/>');
myNumbers.shift();
document.write(myNumbers + '<br/>');
var multiDimArr = new Array();
multiDimArr[0] = new Array();
multiDimArr[1] = new Array();
multiDimArr[2] = new Array();
multiDimArr[3] = 'Multi-dimensional';
multiDimArr[0][0] = 10;
multiDimArr[0][1] = 20;
multiDimArr[1][0] = 30;
multiDimArr[1][1] = 40;
multiDimArr[2][1] = 50;
document.write(multiDimArr[1][0]);
</script>
</body>
</html>
19 changes: 19 additions & 0 deletions lesson07/example3b-pgc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Array map() Method</title>
</head>
<body style="margin-bottom: 25px;">
<h2>CIW JavaScript Specialist</h2>
<h3>Array map() Method</h3>
<script type="text/javascript">
var arr = [0, 1, 2];
var arr_call = arr.map(function add(num) {
return num + 100;
});
document.write(arr + '<br>');
document.write(arr_call);
</script>
</body>
</html>
37 changes: 37 additions & 0 deletions lesson07/example4-pgc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Date Object</title>
</head>
<body>
<h2>CIW JavaScript Specialist</h2>
<h3>Date Object</h3>
<script type="text/javascript">
var theMonths = new Array('January','February','March',
'April','May','June','July','August','September',
'October','November','December');
var weekDays = new Array('Sunday','Monday','Tuesday',
'Wednesday','Thursday','Friday','Saturday');
var currentDate = new Date();
document.write(currentDate + '<br/>');
document.write('Current Month is ' + currentDate.getMonth() +
'<br/>');
document.write('Current Month is ' +
theMonths[currentDate.getMonth()] + '<br/>');
document.write('Current Day is ' +
weekDays[currentDate.getDay()] + '<br/>');
document.write('Current Year is ' +
currentDate.getYear() + '<br/>');
document.write('Current Full Year is ' +
currentDate.getFullYear() + '<br/>');
document.write('Time is ' + currentDate.getTime() + '<br/>');
var christmasDay = new Date();
christmasDay.setDate(25);
christmasDay.setMonth(11);
christmasDay.setYear(christmasDay.getFullYear() + 1);
document.write('Christmas next year is ' + christmasDay +
'<br/>');
</script>
</body>
</html>
25 changes: 25 additions & 0 deletions lesson07/example5-pgc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Timer</title>
<script type="text/javascript">
function runClock() {
var currentTime = new Date();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
var seconds = currentTime.getSeconds();
var timeString = hours + ':' + minutes + ':' + seconds;
document.timeForm.timeNow.value = timeString;
setTimeout('runClock()', 1000);
}
</script>
</head>
<body onload="runClock()">
<h2>CIW JavaScript Specialist</h2>
<h3>Timer</h3>
<form name="timeForm">
<input type="text" name="timeNow">
</form>
</body>
</html>