From 2ac7efc295bf78fb47acf32a1b01bd390ecd5688 Mon Sep 17 00:00:00 2001 From: erincrogers Date: Tue, 24 Mar 2020 19:49:01 -0500 Subject: [PATCH 1/3] my first JS commit --- 01week/helloworld.js | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 01week/helloworld.js diff --git a/01week/helloworld.js b/01week/helloworld.js new file mode 100644 index 000000000..59aba0d86 --- /dev/null +++ b/01week/helloworld.js @@ -0,0 +1,5 @@ +'use strict' + +console.log ("Hello World!") + + From 885084add41b53d36ec0b496017f1bcff8d79d95 Mon Sep 17 00:00:00 2001 From: erincrogers Date: Tue, 24 Mar 2020 20:28:20 -0500 Subject: [PATCH 2/3] test commit for datatypes branch --- 01week/datatypes.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/01week/datatypes.js b/01week/datatypes.js index e69de29bb..633e61f25 100644 --- a/01week/datatypes.js +++ b/01week/datatypes.js @@ -0,0 +1,20 @@ +'use strict' +//write a javascript program to display the current date and time. +let now = new Date (); + +console.log (now); + +//JS program to convert a number to a string +const theNumber = 5; +const theString = theNumber.toString(); + +console.log("The type of theString variable is", (typeof theString)); +console.log("The type of theNumber variable is", (typeof theNumber)); +console.log("The string is", theNumber.toString()); +console.log("the number is ", theNumber); + +//write a JS program to convert a string to a number +const theOtherString = "11"; +const theOtherNumber = parseInt(theOtherString, 10); +console.log("The otherString type is ", (typeof theOtherString)); +console.log("The otherString type is ", (typeof theOtherNumber)); From bae1f2fc4db989804a12283f542dbb67220cd322 Mon Sep 17 00:00:00 2001 From: erincrogers Date: Tue, 31 Mar 2020 19:59:23 -0500 Subject: [PATCH 3/3] sending files up to the mothership --- 01week/datatypes.js | 20 ----- 01week/helloworld.js | 1 - 01week/javascripting/datatypes.js | 114 ++++++++++++++++++++++++++ 01week/javascripting/index.html | 21 +++++ 01week/javascripting/main.js | 128 ++++++++++++++++++++++++++++++ 5 files changed, 263 insertions(+), 21 deletions(-) delete mode 100644 01week/datatypes.js create mode 100644 01week/javascripting/datatypes.js create mode 100644 01week/javascripting/index.html create mode 100644 01week/javascripting/main.js diff --git a/01week/datatypes.js b/01week/datatypes.js deleted file mode 100644 index 633e61f25..000000000 --- a/01week/datatypes.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict' -//write a javascript program to display the current date and time. -let now = new Date (); - -console.log (now); - -//JS program to convert a number to a string -const theNumber = 5; -const theString = theNumber.toString(); - -console.log("The type of theString variable is", (typeof theString)); -console.log("The type of theNumber variable is", (typeof theNumber)); -console.log("The string is", theNumber.toString()); -console.log("the number is ", theNumber); - -//write a JS program to convert a string to a number -const theOtherString = "11"; -const theOtherNumber = parseInt(theOtherString, 10); -console.log("The otherString type is ", (typeof theOtherString)); -console.log("The otherString type is ", (typeof theOtherNumber)); diff --git a/01week/helloworld.js b/01week/helloworld.js index 59aba0d86..3f1453e28 100644 --- a/01week/helloworld.js +++ b/01week/helloworld.js @@ -2,4 +2,3 @@ console.log ("Hello World!") - diff --git a/01week/javascripting/datatypes.js b/01week/javascripting/datatypes.js new file mode 100644 index 000000000..9f876293e --- /dev/null +++ b/01week/javascripting/datatypes.js @@ -0,0 +1,114 @@ +'use strict' +//write a javascript program to display the current date and time. +console.log("inside my datatypes.js file"); +let myDate = new Date (); + +console.log("the current date is", myDate); + +//get the span from the page/document +let mySpan = document.getElementById("theTime"); + +//change what theinner text of the span says +mySpan.innerText = myDate.toString(); + +// //JS program to convert a number to a string +const theNumber = 5; +const theString = theNumber.toString(); + +console.log("The type of theString variable is", (typeof theString)); +console.log("The type of theNumber variable is", (typeof theNumber)); +console.log("The string is", theNumber.toString()); +console.log("the number is ", theNumber); + +// //write a JS program to convert a string to a number +const theOtherString = "11"; +const theOtherNumber = parseInt(theOtherString, 10); +console.log("The otherString type is ", (typeof theOtherString)); +console.log("The otherString type is ", (typeof theOtherNumber)); + + +//Write a JavaScript program that takes in different datatypes and prints out whether they are a +// Boolean +// Null +// Undefined +// Number +// NaN +// String + +console.log('typeof false', typeof false); +console.log('typeof null', typeof null); +console.log('typeof something', typeof something); +console.log('typeof 10', typeof 10); +console.log('typeof NaN', typeof NaN); +console.log('typeof "JS is hard!"', typeof "JS is hard!"); + + +// Write a JavaScript program that adds 2 numbers together. +function add() { + var x = Number(document.getElementById('x').value); + var y = Number(document.getElementById('y').value); + + document.getElementById('result').innerHTML = x + y; + return false; +} + +document.getElementById('go').addEventListener('click', add); + +//Write a JavaScript program that runs only when 2 things are true. + +Function areStrings(thing1, thing2) { + + Console.log(“thing1 =”, thing1); + Console.log(“thing2 =”, thing2); + + Let type1 = typeof thing1; + Let type2 = typeof thing2; + + If(type1 == ‘string’ && type2 ==’string’) { + Console.log(“they are strings”); + } else { + Console.log(“they are not all strings); + } +} + +areStrings(“Mark”, “Bob”); +areStrings(5, ”Matt”); + + + +//Write a JavaScript program that runs when 1 of 2 things are true. + +Function areStrings(thing1, thing2) { + + Console.log(“thing1 =”, thing1); + Console.log(“thing2 =”, thing2); + + Let type1 = typeof thing1; + Let type2 = typeof thing2; + + If(type1 == ‘string’ && type2 !==’string’) { + Console.log(“BINGO! Only one is a string.”); + } else { + Console.log(“Sorry, something is off."); + } +} + +areStrings(“Mark”, “Bob”); +areStrings(5, ”Matt”); + +// Write a JavaScript program that runs when both things are not true. + +Function areStrings(thing1, thing2) { + + Console.log(“thing1 =”, thing1); + Console.log(“thing2 =”, thing2); + + Let type1 = typeof thing1; + Let type2 = typeof thing2; + + If(type1 !== ‘string’ && type2 !==’string’) { + Console.log(“Neither are strings”); + } + + areStrings(“Mark”, “Bob”); + areStrings(5, ”Matt”); diff --git a/01week/javascripting/index.html b/01week/javascripting/index.html new file mode 100644 index 000000000..559217fbb --- /dev/null +++ b/01week/javascripting/index.html @@ -0,0 +1,21 @@ + + + + + + Document + + +

Hello World

+

The Current Time Is + +

+
+ + + +
+
+ + + diff --git a/01week/javascripting/main.js b/01week/javascripting/main.js new file mode 100644 index 000000000..0da2c65af --- /dev/null +++ b/01week/javascripting/main.js @@ -0,0 +1,128 @@ +'use strict' + +console.log("Inside my main.js file"); + +let myDate = new Date (); + +console.log("the current date is", myDate); + +//get the span from the page/document +let mySpan = document.getElementById('theTime'); + +//change what theinner text of the span says +mySpan.innerText = myDate.toString(); + +// //JS program to convert a number to a string +const theNumber = 5; +const theString = theNumber.toString(); + +console.log("The type of theString variable is", (typeof theString)); +console.log("The type of theNumber variable is", (typeof theNumber)); +console.log("The string is", theNumber.toString()); +console.log("the number is ", theNumber); + + +// //write a JS program to convert a string to a number +const theOtherString = "11"; +const theOtherNumber = parseInt(theOtherString, 10); +console.log("The otherString type is ", (typeof theOtherString)); +console.log("The otherString type is ", (typeof theOtherNumber)); + + +//Write a JavaScript program that takes in different datatypes and prints out whether they are a +// Boolean +// Null +// Undefined +// Number +// NaN +// String + +console.log('typeof false', typeof false); +console.log('typeof null', typeof null); +console.log('typeof something', typeof something); +console.log('typeof 10', typeof 10); +console.log('typeof NaN', typeof NaN); +console.log('typeof "JS is hard!"', typeof "JS is hard!"); + + +// Write a JavaScript program that adds 2 numbers together. +function add() { + var x = Number(document.getElementById('x').value); + var y = Number(document.getElementById('y').value); + + document.getElementById('result').innerHTML = x + y; + return false; +} + +document.getElementById('go').addEventListener('click', add); + +//Write a JavaScript program that runs only when 2 things are true. + +Function areStrings(thing1, thing2) { + + Console.log(“thing1 =”, thing1); + Console.log(“thing2 =”, thing2); + + Let type1 = typeof thing1; + Let type2 = typeof thing2; + + If(type1 == ‘string’ && type2 ==’string’) { + Console.log(“they are strings”); + } else { + Console.log(“they are not all strings); + } +} + +areStrings(“Mark”, “Bob”); +areStrings(5, ”Matt”); + + + +//Write a JavaScript program that runs when 1 of 2 things are true. + +Function areStrings(thing1, thing2) { + + Console.log(“thing1 =”, thing1); + Console.log(“thing2 =”, thing2); + + Let type1 = typeof thing1; + Let type2 = typeof thing2; + + If(type1 == ‘string’ && type2 !==’string’) { + Console.log(“BINGO! Only one is a string.”); + } else { + Console.log(“Sorry, something is off."); + } +} + +areStrings(“Mark”, “Bob”); +areStrings(5, ”Matt”); + +// Write a JavaScript program that runs when both things are not true. + +Function areStrings(thing1, thing2) { + + Console.log(“thing1 =”, thing1); + Console.log(“thing2 =”, thing2); + + Let type1 = typeof thing1; + Let type2 = typeof thing2; + + If(type1 !== ‘string’ && type2 !==’string’) { + Console.log(“Neither are strings”); + } + + areStrings(“Mark”, “Bob”); + areStrings(5, ”Matt”); + +//only finish questions 4-8 as homework from step 1 +// the DOM the sum of 5 and 6 equals 11 - let javascript fill in answer scaffolding provided in index.html +//just do 3 or 4 not all of them from the DOM assignment + +//the following comments are in response to an on click question from Erica + +// let mySpan = document.getElementById("theTime"); +// mySpan.addEventListener('click', function(){ +// mySpan.innerText = myDate-toString(); + +// }) \ No newline at end of file