diff --git a/01week/datatypes.js b/01week/datatypes.js index 063141ebe..bc3e6ca6b 100644 --- a/01week/datatypes.js +++ b/01week/datatypes.js @@ -1,23 +1,58 @@ -Date(); //Display Date and Time +//Write a JavaScript program to display the current day and time. -.toString(); //Converts a number to a string +let currentDate = new Date(); -Number(''); //Converts a string to a number +console.log("The current date and time is", currentDate); -Boolean(); //Takes in different data types and prints out whether its a boolean +//Write a JavaScript program to convert a number to a string. -console.log(typeof ); //Checking if different data types is a Boolean, Null, Undefined, Number, NaN, String +var num = 15; +var n = num.toString(); -console.log(12 + 12); //Adds two numbers together +console.log("The number is", num); +console.log("The string representing the number is", n); -if (x==true && y==true) { - console.log("true") - } //Program that runs only of both values are true +//Write a JavaScript program to convert a string to the number. -if (x==true || y==true) { - console.log("true") - } //Program that runs only if one of the values is true +var string = "222"; +var w = Number(string); - if (x!==true && y!==true) { - console.log("true") - } //Program that only runs of both calues are not true \ No newline at end of file +console.log("My 222 string changed to a number is", w); + +//Write a JavaScript program that takes in different datatypes and prints out their datatype + +console.log( + "This program will tell you the data type of a value using typeof followed by the value" +); + +typeof "heyyo"; + +var num1 = 2; + +var num2 = 44; + +console.log("The two num variables added together are:", num1 + num2); //This is a program that will add the two "num" variables together. + +x = true; + +y = true; + +if (x == true && y == true) { + console.log("both are true"); +} //This is a program that only runs of both of the variables are true. + +x = true; + +y = 0; + +if (x == true || y == true) { + console.log("one is true"); +} //This is a program that will only run if one of the variables is true. + +x = 5; + +y = 6; + +if (x !== true && y !== true) { + console.log("both are not true"); +} //This is a program that will only run if both of the variables are not true.