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
61 changes: 61 additions & 0 deletions 01week/datatypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// 1. Write a JavaScript program to display the current day and time.
let rightNow = new Date();
console.log('Today is', rightNow);
// 2. Write a JavaScript program to convert a number to a string.
let num = 4;
console.log(num.toString());
// 3. Write a JavaScript program to convert a string to the number.
let str = '4';
let otherStr = parseInt(str);
console.log(otherStr);
// 4. Write a JavaScript program that takes in different datatypes and prints out whether they are a:
// p0. Boolean
let boolean = true;
console.log(typeof boolean);
// p1. Null
let nully;
console.log(typeof nully);
// p2. Undefined
let undies;
console.log(typeof undies);
// p3. Number
console.log("this is part two using this varible again",typeof str)
// p4. NaN


// p5. String
let whatsThis = "Christopher Trevino";
console.log(typeof whatsThis);

// 6. Write a JavaScript program that adds 2 numbers together.
let x = 5;
let y = 15;
let total = x + y;
console.log(total);
// 7. Write a JavaScript program that runs only when 2 things are true.
function twoThingTrue() {
if (x === 5 && y === 15) {
return true;

}

}
console.log(twoThingTrue())

// 8. Write a JavaScript program that runs when 1 of 2 things are true.
function oneOfTwo() {
if (x === 5 || y === 10) {
return true;
} else {
return "If this logs both came out as false"
}

}
console.log(oneOfTwo())
// 9. Write a JavaScript program that runs when both things are not true.
function bothFalse(){
if (x === 10 || y === 5) {
return false
}
}
console.log(bothFalse());
9 changes: 8 additions & 1 deletion 01week/helloworld.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
"use strict"

console.log("Hello World!");
console.log("Hello World!");

let x = 7;
let y = 8;

let z = x+y;

console.log("The value of Z is ", z);