Web browser result: 10 + y= 22Explanation:var (means variable, optional) This are used to hold values and expressions.let variable y = 12.Mathematical expression= let variable x= 10 + y (where y is equal to 12)document .write display the result: 10 + y= 22
If you add a numeric value and a text or string value, the result will be a text or stringExamples: Statement Resultz= 10+5; 15z= “3”+ “3”; 33z= 8+ “15”; 815z= “11”+12; 1112
• <script>• z="13"+"13";• x= 13+13;• document.write(""+z+"");• alert(""+x+"");• </script>• Result= 1313 (because values on z are considered as “text values”)• Result= 26(because values on x are numeric values)
• <script>• var z= parseFloat("13");• var x= 13• var y= z + x;• document.write(""+y+"");• </script>RESULT= z + x = 26• 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.
COMPUQUIZ/EXERCISES1. A symbol or other character indicating an operation that acts on one or more elements.2. This are used to hold values and expressions.3. Write the code for the following:variable x = 33variable y= 10 + xPut the result in an alert box