JavaScript Basic

5 flashcards · Programming Languages · by Daniel Blackbird

  1. write a sample JavaScript Functions that product two variable from arguments function myFunction(p1, p2) { return p1 * p2; // The function returns the product of p1 and p2 }

  2. JavaScript Data Types: How Declaring (Creating) and assign variable this semi-code var pi = 3.14; var person = "John Doe"; var answer = 'Yes I am!';

  3. Multi-line Comments this semi-code /* The code below will change the heading with id = "myH" and the paragraph with id = "myP" in my web page: */

  4. Single Line Comments this semi-code // Change heading:

  5. write a code that add to variable together and show in output x=5 y=6 z=x+y print => z -------------------- <script> var x, y, z; // Statement 1 x = 5; // Statement 2 y = 6; // Statement 3 z = x + y; // Statement 4 document.getElementById("demo").innerHTML = "The value of z is " + z + "."; </script>