/    Sign up×
Community /Pin to ProfileBookmark

Ok, so i’m a student, and my whole class has an assignment to bring in one question for a quiz that we would make ourselves, but I’m having problems asnswering some of the other kids’ questions. These were not all the questions, but I got most on my own. If anyone could help me out, here are some…..

1) Describe the use of { } and [ ] ??
2) Write an HTML for an image tag named “pet” holding an image file named “cat.jpg”. Write a javascript function that will make the image in that tag be “dog.jpg”
3) Write the code to make a call to the function move() every 200 milliseconds. (Hint: this is a single line) how many times per second is this? what would the # be for once every 2 seconds?
4) in the getObject function , what do the IF conditions do (for example, IF (document.getElementById) )?
5) Write a Javascript SWITCh statement that will display alert boxes with the # of days in a month, based on the value of a variable MON holding a name for a month. This requires calling ALERT function with an appropriate string. Assume it is not a leap year.
6) Describe the general use of setInterval?
7) Describe 2 different ways of programming events( setting up event handleing) in Javascript ?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@javaNoobieOct 14.2004 — 1) Describe the use of { } and [ ] ??[/quote] '[]' used in arrays. '{}' used to group block of codes together. (kinda hard to explain the braces)
<i>
</i>var arr1 = new Array()
arr1[0] = 'Hello'

function someFunction(){
if(arr1[0]=='Hello'){
//codes within the 'if' braces will run if condition is true
}
}

2) Write an HTML for an image tag named "pet" holding an image file named "cat.jpg". Write a javascript function that will make the image in that tag be "dog.jpg"[/quote]
<i>
</i>&lt;img name="pet" src="cat.jpg"&gt;

function changeImg(){
document.images['pet'].src = "dog.jpg";
}

3) Write the code to make a call to the function move() every 200 milliseconds. (Hint: this is a single line) how many times per second is this? what would the # be for once every 2 seconds?
[/quote]

5 times per second. Each second is 1000 milliseconds, hence 2 seconds will be 2*1000 = 2000 milliseconds.
setInterval("move()",200)
4) in the getObject function , what do the IF conditions do (for example, IF (document.getElementById) )?[/quote]Check whether the condition specified in the 'if' statement returns [i]true[/i]. If [i]true[/i] it will run the codes within the 'if' block.
5) Write a Javascript SWITCh statement that will display alert boxes with the # of days in a month, based on the value of a variable MON holding a name for a month. This requires calling ALERT function with an appropriate string. Assume it is not a leap year. [/quote]Check out the [url=http://www.w3schools.com/js/tryit.asp?filename=tryjs_switch]example[/url] at w3schools.
6) Describe the general use of setInterval?[/quote]Duh.. the function name setInterval() already describes itself. Go figure.
7) Describe 2 different ways of programming events( setting up event handleing) in Javascript ?[/quote]Very vague.
×

Success!

Help @br8kd0wn16 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...