From 5809ca39f286c4328e8f87524bb8410181c0b6af Mon Sep 17 00:00:00 2001 From: Cris Smith Date: Thu, 10 Jan 2019 17:40:25 -0600 Subject: [PATCH 1/2] initial commit --- 01week/datatypes.js | 100 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/01week/datatypes.js b/01week/datatypes.js index e69de29bb..4ec77935e 100644 --- a/01week/datatypes.js +++ b/01week/datatypes.js @@ -0,0 +1,100 @@ + + +// Write a JavaScript program to display the current day and time. + + +const dateFunc = (day, time) => { + console.log("Today is: " + day + ", the time is now: " + time) +} + +dateFunc("Thursday","7:00pm") + +//Write a JavaScript program to convert a number to a string. + +const functionX = (num1)=> { + if (typeof num1 === 'number'){ + return num1.toString() + } + } + functionX(6); + + +// Write a JavaScript program to convert a string to the number. + +const convStringFunction = (arg1)=> { + return parseInt(arg1); +} +convStringFunction('109'); + +/* Write a JavaScript program that takes in different datatypes and prints out whether they are a: +Boolean +Null +Undefined +Number +NaN +String */ + + +const checkTypeFunction = (myDatatype) => { + +if(typeof myDatatype === 'boolean') { + console.log('Boolean'); +}; +if (typeof myDatatype === 'null') { + console.log('Null'); +}; +if (typeof myDatatype === 'undefined') { + console.log('Undefined'); +}; + +if (typeof myDatatype === 'number') { + console.log('Number'); +}; +if (typeof myDatatype === NaN) { + console.log('NaN'); +}; + +if (typeof myDatatype === 'string') { + console.log('String'); + } + +} + +checkTypeFunction('cat'); + + + +// Write a JavaScript program that adds 2 numbers together. + +const addFunction = (num1, num2) => { + return num1 + num2; +} +addFunction (6,7); + +//Write a JavaScript program that runs only when 2 things are true. + +const trueFunction = (arg1, arg2) => { +if (arg1 && arg2) { + return 'both are true' + } +} +trueFunction('cat',6); + + +//Write a JavaScript program that runs when 1 of 2 things are true. +const oneTrueFunction = (arg1, arg2) => { + if ( arg1 || arg2 === true) { + return 'one is true' + } +} +oneTrueFunction('cat',0) + + +//Write a JavaScript program that runs when both things are not true. */ + +const notTrueFunction = (arg1, arg2) => { + if (arg1 && arg2 != true) { + return 'both are false' + } + } + notTrueFunction(0,0); From d77538fbf3cc2c774b9eeb21f470b329ad1244ab Mon Sep 17 00:00:00 2001 From: Cris Smith Date: Sun, 13 Jan 2019 20:48:15 -0600 Subject: [PATCH 2/2] updated datatypes file --- 01week/datatypes.js | 1 + 1 file changed, 1 insertion(+) diff --git a/01week/datatypes.js b/01week/datatypes.js index 4ec77935e..8e1ece699 100644 --- a/01week/datatypes.js +++ b/01week/datatypes.js @@ -96,5 +96,6 @@ const notTrueFunction = (arg1, arg2) => { if (arg1 && arg2 != true) { return 'both are false' } + } notTrueFunction(0,0);