Thursday, August 25, 2005

Adaptive (sort of) comments tag- code

Continued from here.

I can't get the HTML code to be displayed. The instructions saved as a *.txt file available here.

[Yvy has highlighted a problem: the code cannot be shown by certain browsers because IE will automatically read the stuff and execute the instructions given in the code. Firefix users should be fine. Solution: switch over to Firefox lar...what are you guys waiting for? For your 4 grilled chicken wings? Anyway, IE users, "Save target as..." and save codingexercise.txt to your hard disc as a txt file. Make sure you change it from HTML to txt format. IE is fiddly. I'll see if i can get browsers to display the code. Maybe tonight... Also, come to the dark Firefox side.]

The variable a represents the number of comments. The various if conditions are such that if (condition) is true, {do something}. If (condition) is not true, proceed to next (condition). The last one is a simple else {do this}.

I have not tried these, but it might be possible to design more complicated conditions, such as:

if (a%2==0)
-> If a divided 2 has remainder zero (implies that a is an even number)

if (a!=5)
-> If a is not equal to 5

if (a==3 || a==7)
-> If a is 3 or 7
-> With ||, at least one of the conditions must be satisfied

if (a>=10 && a<20)> if a is greater than or equal to 10 AND smaller than 20 (for a = 10, 11, 12... 19)
-> with &&, both conditions must be satisfied


For more information.

Labels: