guidelines for javascript

guidelines for javascript - Computer Applications for...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Computer Applications for Business, CS170 Fall 2010 Guidelines: Part 1: 1) How to start JavaScript in HTML? <script type=”text/javascript”> // the code goes here </script> 2) Understand the concept of variables. 3) How to declare variables – syntax, initialization? var a,b; a=0; b=0; or //everything in separate lines var a; var b; a=0; b=0; or // everything in one line var a=0,b=0; // if you don’t have to initialize b var a=0,b; 4) How many data types and how do you distinguish them? 3 data types: number, boolean and text Examples: Number: 1, 2.0, -1, -12.34 boolean: true, false string (text): “anything inside quotes” Note: The quotes in a word document and the quotes in a notepad are different. So, if you copy and paste it from here, make sure you delete the quotes and re-type them. 5) What’s the difference between, say, value “10” and 10? “10” is of string datatype 10 is number datatype 6) Understand the concepts of functions – syntax Syntax or usage: function_name( ); 7) What is an argument in a function? function(argument1,argument2); Anything that you pass when calling a function. 8) How do you write HTML through JavaScript? document.write(“html code”); 9) What function do you use to show something on a window?
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Computer Applications for Business, CS170 Fall 2010 alert(“a function to show something on a window”); 10) How do you take input from the user? (What functions do you use) a. How do you take text input from the user? var text = prompt(“enter some text”,””); b. How do you take number input from the user? var num = 1*prompt(“enter some text”,””); 11) How do you convert text to a number? 1*”10” equals to number 10 12) What the hell is NaN? NaN means Not a Number. This value occurs if you simply use a variable without giving a value to it. var a,b=0; b = a*2; //b is NaN This value also occurs if you convert an invalid text to a number a = 1*”text”; //a is NaN 13) How do you write equations in JavaScript? Is a = b + c same as saying b + c = a? No, when assigning values, the left hand side should always be a variable. The right hand side expression is first computed. Then, the result is assigned to the left hand side variable. If you want to check if both are equal (a == b+c) then you can interchange them (b+c == a is valid too) 14) What is the equivalent box used in flowchart for document.write?
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

guidelines for javascript - Computer Applications for...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online