diff --git a/INFO-1272 (JS 1)/Notes/Midterm/index.html b/INFO-1272 (JS 1)/Notes/Midterm/index.html index 1f72c53..8c7ee8a 100644 --- a/INFO-1272 (JS 1)/Notes/Midterm/index.html +++ b/INFO-1272 (JS 1)/Notes/Midterm/index.html @@ -132,6 +132,41 @@
+

JavaScript Global Functions

+
    +
  1. Describe the operation and the return for the following global functions:
  2. + +
+

Answers:

+ +
+ +

JavaScript String Methods

+
    +
  1. Describe the operation and the return for the following String methods.
  2. + +
+

Answers:

+ +

Playground

Interactive JavaScript follows

diff --git a/INFO-1272 (JS 1)/Notes/Midterm/index.js b/INFO-1272 (JS 1)/Notes/Midterm/index.js index e69de29..35af291 100644 --- a/INFO-1272 (JS 1)/Notes/Midterm/index.js +++ b/INFO-1272 (JS 1)/Notes/Midterm/index.js @@ -0,0 +1,51 @@ +for (var i = 1; i < 10; i++) { + console.log("Ran " + i + " time(s).") +}; + +console.log(window.confirm("Feel prepared?")); // true or false + +var question = ("50" === 50); +console.log(question); + +var question2 = (true && false); +console.log(question2); + +var question3 = (true || false); +console.log(question3); + +// VAR price = 35.6; <-- WRONG +var price = 35.6; // <-- RIGHT + +var city = "London"; + +if (city.toLowerCase() === "london") { + console.log("I live there too!"); +} else { + console.log("I dont know where that is.") +} + +var userName = window.prompt("Please enter your name:"); +greetUser(userName); + +var radius = window.prompt("Please enter circle radius:"); +calcCirc(radius); + +var testNum = window.prompt("Number to test for even:"); +isEven(testNum); + +function greetUser(userName) { + alert("Hello " + userName + " welcome to the page"); +} + +function calcCirc(radius) { + var Circ = ((2 * Math.PI) * radius).toFixed(2); + alert("Circumference is: " + Circ + " Inches."); +} + +function isEven(number) { + if (number % 2 == 0) { + console.log(number + " is even"); + } else { + console.log(number + " is odd"); + } +} \ No newline at end of file