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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
18 changes: 18 additions & 0 deletions 01week/datatypes.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<h1>JS 211</h1>
<button type="button" onclick="displayDate()">Display date</button>
<p id= "showDate"></p>
<div>'A' is declared as a <span id= "booleanTest"></span></div>
<div>The sum of 5 + 11 is <button onclick= "displaySum()">Sum</button></div>
<span id = "sum"></span>
<div>The data type of 5 is a <button id= "numDataType">Data Type</button></div>
<span id = "typeOfNum"></span>
</body>
<script src="datatypes.js"></script>
</html>
177 changes: 177 additions & 0 deletions 01week/datatypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
'use strict'

//program to display current day and time

/*let now = new Date();
console.log("the current date and time", now);

//write js program to convert num to 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);

//covert a string to the number
const theOtherString = "4.5";
const theOtherNumber = parseInt(theOtherString, 10);
console.log("The otherString type is", (typeof theOtherString));
console.log("The otherNumber")


(counting in base 10)
0,1,2,3,4,5,6,7,8,9,10,11

(counting in base 2)
0, 1, 10, 11, 100, 111, 1000

(counting in base 16)
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,A , B, C, D ,E ,F
*/
// **THIS IS INCREDIBLY IMPORTANT THAT YOU DO BOTH SECTIONS!!! You will be doing only front-end work in 421 and you need to brush up on your HTML elements**


// ***************************
// PART ONE
// ***************************
// Write a JavaScript program to display the current day and time, start with:
//console.log(new Date)

const displayDate = () => {
const currentDate = new Date()

document.getElementById("showDate").innerHTML = currentDate;
}



// Write a JavaScript program to convert a number to a string.

const num = 100;
console.log(num, typeof num);

const grade = String(num);
console.log(grade, typeof grade)



// Write a JavaScript program to convert a string to the number.
const amount = "10.25"
console.log(amount, typeof amount);

const a = parseFloat(amount);
console.log(a, typeof a);

// Write a JavaScript program that takes in different datatypes and prints out whether they are a:
// * Boolean
let untrue = false;
//console.log(a, typeof a)
document.getElementById("booleanTest").innerText = typeof a;


// * Null
let b = null;
console.log(b, typeof b)

// * Undefined
let c;
console.log(c, typeof c)

// * Number
document.getElementById("numDataType").addEventListener("click", function(){
const number = 5;
document.getElementById("typeOfNum").innerHTML = typeof number;
});

// * NaN
const NotANum = NaN;
console.log(NotANum, typeof NotANum)

// * String
const greeting = "Hello there";
console.log(greeting, typeof greeting)



// Write a JavaScript program that adds 2 numbers together.
const displaySum = () => {
const num1 = 5;
const num2 = 11;

const total = num1 + num2;
/*document.getElementById("sum").addEventListener("click", function(){
const num1 = 5;
const num2 = 11;
const total = num1 + num2;
document.getElementById("sumOfTwoNum").innerHTML = total;
});*/

document.getElementById("sum").innerHTML = total;
}

// Write a JavaScript program that runs only when 2 things are true.
const value1 = 10;
const value2 = 20;

const bothAretrue = (arg1, arg2) => {
if (arg1 && arg2){
return true
} else {
return false
}
}

truth(value1, value2)



// Write a JavaScript program that runs when 1 of 2 things are true.

const numeroUno = 13;
const numeroDos = 0;

const oneIsTrue = (argue1, argue2) => {
if (argue1 || argue2){
return true
} else {
return false
}
}

oneIsTrue(numeroUno, numeroDos)
// Write a JavaScript program that runs when both things are not true.

const empty = " ";
const zero = 0;

const bothAreFalse = (argument1, argument2) => {
if (argument1 && argument2){
return true
} else {
return false
}
}

oneIsFalse(empty, zero)

// ***************************
// PART TWO
// ***************************

// 1. download Live-Server by Ritwick Dey,
// 2. reload VS Code,
// 3. click the "Go Live" button
// 4. Go local host 5500 or http://127.0.0.1:5500/index.html to see your web page
// 5. Or go use the `npm start` command and navigate to localhost:8080 (ctrl + C to close)
// 6. go to `index.html`
// 7. create inputs, buttons and event listeners that render the code blocks you built above to the DOM.




// Additional Resources
// Video1: https://player.vimeo.com/video/377147232
// Video2: https://www.youtube.com/embed/bkvH28PXLWc
// Video3: https://www.youtube.com/embed/TrGI9Yki-24
1 change: 1 addition & 0 deletions 01week/helloworld.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('Hello World');
33 changes: 32 additions & 1 deletion 01week/rockPaperScissors.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,41 @@ const rl = readline.createInterface({
// the function that will be called by the unit test below
const rockPaperScissors = (hand1, hand2) => {

hand1 = hand1.toLowerCase().trim();
hand2 = hand2.toLowerCase().trim();

if (hand1 === hand2) {
return "It's a tie!"
} else if (hand1 === 'rock'){
if (hand2 === 'paper'){
return "hand2 wins"
} else if (hand2 === 'scissors'){
return "hand1 wins!"
}
}

else if (hand1 === 'paper'){
if (hand2 === 'scissors'){
return "hand2 wins!"
} else if (hand2 === 'rock'){
return "hand1 wins!"
}
}

else if (hand1 === 'scissors'){
if(hand2 === 'rock'){
return "hand2 wins!"
} else if (hand2 === 'paper'){
return "hand1 wins!"
}
}
}


// Write code here
// Use the unit test to see what is expected

}


// the first function called in the program to get an input from the user
// to run the function use the command: node main.js
Expand Down
23 changes: 23 additions & 0 deletions 02week/pigLatin.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<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>Pig Latin</h1>
<div>
<label>English: </label>
<input id= "Input"></input>
</div>
<div id= "Translate">
<button id ="btn">Test Word</button>
</div>
<br><br>
<label>Pig Latin: </label>
<input placeholder="Output" id= "Output"></input>

<script src = "pigLatin.js"> </script>
</body>
</html>
72 changes: 68 additions & 4 deletions 02week/pigLatin.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,82 @@
'use strict';
/*'use strict';

const assert = require('assert');
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
});*/

var userInput = document.getElementById("Input");
var userOutput = document.getElementById("Output");

/*document.getElementById("Translate").onlick = function(){
userOutput.value = pigLatin(userInput.value);
console.log("I got clicked");
};
*/

document.getElementById("btn").onclick = function(){
userOutput.value = pigLatin(userInput.value);
}



const pigLatin = (word) => {
word = word.toLowerCase().trim();
if(checkWord(word.charAt(0))){
return word + "yay";
}else if(checkWord(word.charAt(1))){
//else if(checkWord(word.indexOf[1]))
return word.slice(1) + word.charAt(0) + 'ay';
}
else if(checkWord(word.charAt(2))){//?? two word slice methods below???
return word.slice(2) + word.slice(0, 2) + 'ay';
}
else if(checkWord(word.charAt(3))){
return word.slice(3) + word.slice(0,3) + 'ay';
}
else
return "Invalid input"
};

const checkWord = (word) =>{
//go through the word and
//the if statement checks the word for the vowel
if(word === 'a' || word === 'e' || word === 'i' || word === 'o' || word === 'u'){
return true;
//seperate the word where the vowel is found, and implement the part1, part2,part3 values
}
else{
return false;
}

};
console.log(checkWord('dog'));
console.log(pigLatin('valley'));
console.log("Hello");
//pigLatin( ,);
//??????
//vowelCheck = word.match(/aeiou/gi);
//use a for loop to find tne position of the first vowel
//use indexOf to find the vowel






//1. if the word starts with a vowel, add "yay" to the end
//2. if the word has a vowel:
// a. find the first vowel.
// b. split the word into 2 parts:
// - starting at the beginning and stopping just before the first vowel
// - starting at the first vowel and to the end of the word
// c. make a new word, where you flip the 2 parts
// d. add "ay" to the end of the new word`
// Your code here

}



const getPrompt = () => {
Expand Down Expand Up @@ -48,4 +112,4 @@ if (typeof describe === 'function') {

getPrompt();

}
};
10 changes: 10 additions & 0 deletions 02week/pigLatinDOM.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
for(let i >= 1; i <= 100; i++){
if(i % 3 ===0 && i % 5=== 0){
console.log("FizzBuzz");
}
else if(i % 3 === 0){
console.log("Fizz");
}else if(i % 5 ===0){
console.log("Buzz");
}
};
Empty file added 02week/ticTacToe.hmtl
Empty file.
19 changes: 19 additions & 0 deletions 02week/todo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<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>The best to do tracker</h1>
<ul>
</ul>
<input type= "text" id = "inputText"><button id = "add">add</button>
<style>
.done{
text-decoration: line-through;
}
</style>
<script src= "todo.js"></script>
</body>
</html>
Loading