School of Enterprise Computing & Digital Transformation

Javascript: Datatypes, Operators and Functions

Assignment

  1. Open the developer tools console in your browser Console as explained in section Tools for Developing in Javascript of this tutorial.
  2. Clear the console by clicking the appropriate icon ('bin' in Firefox or 'forbidden' in Chrome).
  3. Do not close the Console until you have finished the work and exported it (instructions for this at the end).
  4. Open this tutorial at section Javascript Operators.
  5. In the Console, write and run code to complete the following tasks.
    • Apply operator + to two numbers.
    • Apply operator + to a string and a number.
    • Apply operator + to two strings.
    • Apply operator == to a string and a number, so that the expression evaluates to true.
    • Apply operator === to any two operands, so that the expression evaluates to true.
    • Apply operator < to two strings, so that the expression evaluates to true.
    • Apply operator && to any two operands, so that the expression evaluates to true.
    • Apply operator ! to any expression, so that the operation evaluates to false.
    • For each type (number, string and boolean), apply operator typeof twice: once on a literal value of that type and once with a complex expression that yields that type.
    • Apply the indexing operator ([]) to extract the first, the second last and the last character from string "TUDublin" and the concatenation opearator (+) to string them together (you should get "Tin" as a result). Be careful with the index ("TUDublin"[0] gives the first character, "TUDublin"[1] gives the second character etc.).
    • Execute one example of using the function alert() and one example of using console.log().
  6. Export the console contents to a file:
    • In Firefox: right-click on any message in the console, click Export visible messages to file, click File, use dialogue to save a file
    • In Chrome: right-click anywhere in the console, click Save as, use dialogue to save a file
  7. Submit the created file by adding it to your lab GitHub repository.