Skip to content
Open
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
Empty file removed 01week/datatypes.js
Empty file.
4 changes: 4 additions & 0 deletions 01week/helloworld.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use strict'

console.log ("Hello World!")

114 changes: 114 additions & 0 deletions 01week/javascripting/datatypes.js
Original file line number Diff line number Diff line change
@@ -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”);
21 changes: 21 additions & 0 deletions 01week/javascripting/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Hello World</h1>
<h1>The Current Time Is
<span id='theTime'></span>
</h1>
<div>
<input id="x">
<input id="y">
<button id="go">+</button>
<div id="result"></div>
</div>
</body>
<script src="main.js"></script>
</html>
128 changes: 128 additions & 0 deletions 01week/javascripting/main.js
Original file line number Diff line number Diff line change
@@ -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();

// })