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
95 changes: 95 additions & 0 deletions 01week/datatypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
'use strict'
// .1write a javascript program to display date and time
let now = new Date();
console.log("the current date and time, now");

//.2, 3 converting a string to a number and so on
const theNumber = 5;
const theString = theNumber.toString();

console.log("string is", theNumber.toString());
console.log("the number is", theNumber);

//.4 creating a boolean
let trueNumber = 50;
let falseNumber = 40;

console.log (typeof trueNumber <= falseNumber);
// //.5 writing a program the add two things together. For some reason it works in repl.it but not here??
let a = Number(prompt("Enter first number"));
let b = Number(prompt("Enter second number"));
alert(a + b);

// //.6 write a program than runs when two things are
let x = 42;
let y = 31;
console.log(typeof x);
console.log(typeof y);

let addBoth = (x, y) => {
if (x < y && y > 0) {
return (x - y)
}
else {
return 'this will be False'
}}
addBoth(x, y);

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

const oneTrue = (input3, input4) => {

let a = document.getElementById("input3").value.trim().toLowerCase();
let b = document.getElementById("input4").value.trim().toLowerCase();

console.log(a);
console.log(b);


if (a == "null" || a == "nan" || a == "undefined" || a == "false" || a == "" || a == '' || a == "0" || a == "-0") {
a = null;
}

if (b == "null" || b == "nan" || b == "undefined" || b == "false" || b == "" || b == '' || b == "0" || b == "-0") {
b = null;
}


console.log(a);
console.log(b);

console.log(typeof a);
console.log(typeof b);






//8.
const bothFalse = (input5, input6) => {

let a = document.getElementById("input5").value.trim().toLowerCase();
let b = document.getElementById("input6").value.trim().toLowerCase();

console.log(a);
console.log(b);


if (a == "null" || a == "nan" || a == "undefined" || a == "false" || a == "" || a == '' || a == "0" || a == "-0") {
a = null;
}

if (b == "null" || b == "nan" || b == "undefined" || b == "false" || b == "" || b == '' || b == "0" || b == "-0") {
b = null;
}

console.log(a);
console.log(b);

console.log(typeof a);
console.log(typeof b);


//.9

3 changes: 2 additions & 1 deletion 01week/helloworld.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use strict"

console.log("Hello World!");
//console.log("La Onda Lives!")

21 changes: 21 additions & 0 deletions 01week/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>Java Ish</title>
</head>
<body>
<h1>Hello World!</h1>
<h1>The current time
<span id="theTime">Click here to set date</span>
</h1>



<h1>The sum of 7 and 15 is
<span id="theSum">Answer?</span>
</h1>
</body>
<script src="./main.js"></script>
</html>
24 changes: 24 additions & 0 deletions 01week/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict'

console.log("inside my main.js file");
//1.display the current time and date
let myDate = new Date();

console.log("The current date is", myDate);
//2.gets the span from page/document
//let mySpan = document.getElementById("theTime");
//3.change the inner text of the span says
//mySpan.innerText = myDate.toString();
//console.log()
//.4
let mySpan = document.getElementById("theTime");
mySpan/addEventListener('click', function(){
mySpan.innerText = myDate.toString();
})



//5.start point//



44 changes: 43 additions & 1 deletion 01week/rockPaperScissors.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,55 @@ const rl = readline.createInterface({
});

// the function that will be called by the unit test below
//the function should return 1 of 3 string
// - 'Its a tie'
// - 'Hand one wins!'
// - 'Hand two wins!'
const rockPaperScissors = (hand1, hand2) => {

// Write code here
// Use the unit test to see what is expected
// Hand 1 & 2
hand1 = hand1.trim().toLowerCase();
hand2 = hand2.trim().toLowerCase();


if (hand1 == hand2 && hand1 !== '' && hand2 !=='') {
console.log("It's a tie!");
return "It's a tie!";
}
else if (hand1 == "rock" && hand2 =="scissors") {
console.log("Hand one wins!")
return "Hand one wins!";
}
else if (hand1 == "rock" && hand2 =="paper") {
console.log("Hand two wins!")
return "Hand two wins!";
}
else if (hand1 == "scissors" && hand2 == "rock") {
console.log("Hand two wins!")
return "Hand two wins!";
}
else if (hand1 == "scissors" && hand2 == "paper") {
console.log("Hand one wins!")
return "Hand one wins!";
}
else if (hand1 == "paper" && hand2 == "rock") {
console.log("Hand one wins!")
return "Hand one wins!";
}
else if (hand1 == "paper" && hand2 == "scissors") {
console.log("Hand two wins!")
return "Hand two wins!";
}
else {
console.log("Invalid input.")
return "Invalid input."
}

}


// the first function called in the program to get an input from the user
// to run the function use the command: node main.js
// to close it ctrl + C
Expand Down Expand Up @@ -48,7 +90,7 @@ if (typeof describe === 'function') {
assert.equal(rockPaperScissors('paper', 'scissors'), "Hand two wins!");
assert.equal(rockPaperScissors('rock', 'scissors'), "Hand one wins!");
});
it('should scrub input to ensure lowercase with "trim"ed whitepace', () => {
it('should scrub input to ensure lowercase with "trim"ed whitespace', () => {
assert.equal(rockPaperScissors('rOcK', ' paper '), "Hand two wins!");
assert.equal(rockPaperScissors('Paper', 'SCISSORS'), "Hand two wins!");
assert.equal(rockPaperScissors('rock ', 'sCiSsOrs'), "Hand one wins!");
Expand Down
Loading