hello so i am taking a javascript class and the teacher asked us to code the fallowing :
Write an entire function named Bold_Name, it should:
Build an HTML string by placing the global variable fullname in between the BOLD tags <B> and </B>
Here is an example of what this string will contain: <B> ... </B>
Use the Javascript return statement to send the string back to the caller
Do not call Bold_Name, or initialize fullname, it will be done for you.
Hint: use the '+' operator to create the string
You aren't declaring a global variable called fullname, much less giving it any value.
HOW is the function being called, HOW is the global variable being initialized?
__________________ ^_^
If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
* The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
You aren't declaring a global variable called fullname, much less giving it any value.
HOW is the function being called, HOW is the global variable being initialized?
well we have to copy paste the code into the website, and the website says not to declare " fullname" and also i dont think we have to call it because the teacher says that will be done by the program it self.
If that is the case, then the only thing that I think needs doing is to change return(fullname); to return fullname;
At least, as far as I can tell.
__________________ ^_^
If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
* The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
The only thing I see missing is the } needed at the end of the function.
I just assumed it was accidentally left out of the copy/paste process. :\
__________________ ^_^
If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
* The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
I think you're going to run into troubles constructing a string like that using the variable as a based. Have a look at it with alerts to show you what is going on...
I don't think it's that stupid (at least in the context of all the other stupid homework assignments we see).
There's nothing in the question that says you have to build the string using +=, so the direct method would certainly apply. You could even, if you were feeling racy, just return that: return "<b>"+fullname+"</b>";
because there's nothing to say that the function has to return fullname, just that it has to use it. If you wanted to build a string in the way that assyrianlegend was, you just as easily could do
Code:
function Bold_Name() {
var str=""
str += "<b>";
str += fullname;
str += "</b>";
return str;
}
Anyway. I guess 3 answers to one question is enough...
Xelawho: Read his homework description again. The function is supposed to use *AND MODIFY* the global variable fullname. *THAT* is why it is so stupid.
The "framework" that will test his code is not even going to LOOK at the return value from the function. And idiotic framework written, as VIPStephan says, to illustrate the worst possible way to do things. Makes sense to me. NOT.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
(Okay...it's still stupid to work on a global, instead of on a passed in value, but never mind. Xelawho's answer is clearly what was expected. The function shouldn't modifiy the value of fullname in any way.)
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.