Archive for the ‘JavaScript’ Category

JavaScript Benchmark: Google Chrome vs Mozilla Firefox vs Internet Explorer 8

Sunday, November 15th, 2009

I’ve been wanting to try Chrome ever since it was released but I was hesitant because I got used to Firefox’s (awesome) extensions. But since there are a couple of Chrome extensions now I decided to try it out.

Before I installed Chrome though, IĀ google’d for benchmarks where Chrome is pitted against other popular browsers like FireFox, Internet Explorer 8, Opera, Safari, et al. Most of the benchmarks focus on how Chrome handles Javascript so I decided to try one of theseĀ online benchmarks myself. And here are the results…

(more…)

JavaScript Code Snippet #4

Friday, March 27th, 2009

Computers are playing an increasing role in education. Write a program that will help an elementary-school student learn multiplication. Use Math.random to produce two positive one-digit integers. It should then display a question such as How much is 6 times 7? The student then types the answer into a text field. Your program checks the student’s answer. If it is correct, display the string Very Good! and generate a new question. If the answer is wrong, display the string No. Please try again. and let the student try the same question again repeatedly until the student finally gets it right. A separate function should be used to generate each new question. This function should be called once when the script begins execution and each time the user answers the question correctly.

(more…)

JavaScript Code Snippet #3

Thursday, March 26th, 2009

One interesting application of computers is the drawing of graphs and bar charts. Write a script that reads five numbers between 1 and 30 out put XHTML text that displays a line containing the same number of adjacent asterisks. For example, if your program reads the number 7, it should output XHTML text that displays *******.

(more…)

JavaScript Code Snippet #2

Thursday, March 26th, 2009

Write a JavaScript program that uses looping to print the following table of values. Output the results in an XHTML table. Use CSS to center the data in each column.

(more…)

JavaScript Code Snippet #1

Wednesday, March 25th, 2009

Write a script that displays the numbers 1 to 4 on the same line, with each pair of adjacent numbers separated by one space.

(more…)