Saturday, 8 November 2014

Week 23: November 3-7: I knew it!

  Hi!

      Oh! We celebrated the  Intramurals 2014. And on Monday, Sir discussed about the JavaScript 3.

Here are examples...

 Conditional Operator



JavaScript also contains a conditional operator that assigns a value to a variable based on some condition.

 It is ok to use conditional operators like a statement like so?

(x == y) ? alert("yo!") : alert("meh!");
Or is it more correct to use it to assign a value like so?
z = (x == y) ? "yo!" : "meh!";

Logical OR Operator



Logical operators are used to determine the logic between variables or values.
Given that x=6 and y=3, the table below explains the logical operators:
OperatorDescriptionExample
&&and(x < 10 && y > 1) is true
||or(x == 5 || y == 5) is false
!not!(x == y) is true


Using Parse Float() Function

     The parseFloat() function parses a string and returns a floating point number.


This function determines if the first character in the specified string is a number. If it is, it parses the string until it reaches the end of the number, and returns the number as a number, not as a string.

Note: Only the first number in the string is returned!
Note: Leading and trailing spaces are allowed.
Note: If the first character cannot be converted to a number, parseFloat() returns NaN.



Taken from:http://www.w3schools.com/jsref/jsref_parsefloat.asp


Signing off...




0 comments:

Post a Comment

// Posted by :Unknown // On :Saturday, 8 November 2014

  Hi!

      Oh! We celebrated the  Intramurals 2014. And on Monday, Sir discussed about the JavaScript 3.

Here are examples...

 Conditional Operator



JavaScript also contains a conditional operator that assigns a value to a variable based on some condition.

 It is ok to use conditional operators like a statement like so?

(x == y) ? alert("yo!") : alert("meh!");
Or is it more correct to use it to assign a value like so?
z = (x == y) ? "yo!" : "meh!";

Logical OR Operator



Logical operators are used to determine the logic between variables or values.
Given that x=6 and y=3, the table below explains the logical operators:
OperatorDescriptionExample
&&and(x < 10 && y > 1) is true
||or(x == 5 || y == 5) is false
!not!(x == y) is true


Using Parse Float() Function

     The parseFloat() function parses a string and returns a floating point number.


This function determines if the first character in the specified string is a number. If it is, it parses the string until it reaches the end of the number, and returns the number as a number, not as a string.

Note: Only the first number in the string is returned!
Note: Leading and trailing spaces are allowed.
Note: If the first character cannot be converted to a number, parseFloat() returns NaN.



Taken from:http://www.w3schools.com/jsref/jsref_parsefloat.asp


Signing off...




Leave a Reply

Subscribe to Posts | Subscribe to Comments

 

Blog Template by YummyLolly.com - Header made with PS brushes by gvalkyrie.deviantart.com
Sponsored by Free Web Space