Skip to content
Open
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';
console.log('here');
//Write a JavaScript program that adds 2 numbers together.
const sumOfTwoNumbers=(num1, num2)=>{
return num1+num2

};

sumOfTwoNumbers(3,2);

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

// function that recieves two items, if those two things are true.
// methods: function, 2 arguments, if/ then statement

const evaluatesToTrue=(arg1, arg2)=> {
if(arg1 && arg2){
return 'both are true'
}else{
return 'nope'
}
};

evaluatesToTrue(4, 6);
evaluatesToTrue(null, 6);


// pasted code

const oneArgumentIsTrue=(arg1, arg2)=> arg1 || arg2;



// 1. Write a JavaScript program to display the current day and time.
const today = new Date();
const day = today.getDay();

// 2. Write a JavaScript program to convert a number to a string.
const num = 15;
const n = num.toString();

// 3. Write a JavaScript program to convert a string to the number.
const stingToNum = '10';
const s = parseInt();

// 4. Write a JavaScript program that takes in different datatypes and prints out whether they are a:
// Boolean
console.log(typeof true);
// expected output: "boolean"

// Null
const person = {firstName: 'Lawerence' , lastName: 'Williams'};
person = null;

// Undefined
console.log(typeof variableNotDeclared);
// expected output: "undefined";

// Number
console.log(typeof 42);
// expected output: "number"

// NaN
isNaN();

// String
console.log(typeof 'dance');
// expected output: "string"

// 5. Write a JavaScript program that adds 2 numbers together.
const sumOfNums= (arg1, arg2)=>{
return arg1 + arg2
};

// 6. Write a JavaScript program that runs only when 2 things are true.
const sumOfNums= (arg1, arg2)=>{
if (typeOf arg1 === typeOf 'number' && typeof 'number'){
return arg1 + arg2
}
};

// 7. Write a JavaScript program that runs when 1 of 2 things are true.
const bothTrue =(arg1, arg2)=>{
if(arg1 && arg2){
return 'true'
}
};

// 8. Write a JavaScript program that runs when both things are not true.
const checkStrings=(a,b,c)=>{
if(typeof a === 'string' && typeof b === 'string' && typeof c === 'string'){
return 'awesome'
}
};
checkStrings('hello', '7', 'no')