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
59 changes: 59 additions & 0 deletions 01week/datatypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//Write a JavaScript program to display the current day and time.
console.log(Date());

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

const numberToString = (num) => {
return num.toString()
}
console.log(numberToString(2));

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

const stringToNumber = (str) => {
return parseInt(str, 10 );
}
console.log(stringToNumber('42'));

/*Write a JavaScript program that takes in different datatypes and prints out whether they are a:
Boolean*/

function isVar(bln){
return typeof bln;
}
console.log(isVar(42));


//Write a JavaScript program that adds 2 numbers together.

function addNums(num1, num2){
return num1 + num2;
}
console.log(addNums(5,2))

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

function twoTrue(x,y){
if(x==1 && y==2){
return addNums(4,5);
}}

console.log(twoTrue(1,2));

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

function oneTrue(x,y){
if(x==1 || y==2){
return addNums(3,3);
}
}
console.log(oneTrue(0,2));

//Write a JavaScript program that runs when both things are not true.
function noneTrue(x,y){
if(!(x==1) && !(y==2)){
return addNums(4,4);
}
}
console.log(noneTrue(12,1));

6 changes: 6 additions & 0 deletions 01week/javascripting/for-loop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
let total = 0;
let limit = 10;
for (i=total; i<limit;){
total += i;
}
console.log(total);
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
<title></title>
</head>
<body>
<h1>Hello World!</h1>
<h1>Hello Josh!</h1>
</body>
</html>
13 changes: 6 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.