Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-06-2012, 01:20 AM   PM User | #16
Logic Ali
Regular Coder

 
Logic Ali's Avatar
 
Join Date: Sep 2010
Location: London
Posts: 959
Thanks: 0
Thanked 198 Times in 193 Posts
Logic Ali will become famous soon enoughLogic Ali will become famous soon enough
Quote:
Originally Posted by Old Pedant View Post

The "framework" that will test his code is not even going to LOOK at the return value from the function.
Without seeing it's source code, how can you possibly know that?

However unnecessary in the circumstances, the requirement was to use return, so it could be critical.
Logic Ali is offline   Reply With Quote
Old 10-06-2012, 01:51 AM   PM User | #17
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,200
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Read my prior answer about needing a new brain.

I flat out misread the original post.
__________________
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.
Old Pedant is offline   Reply With Quote
Old 10-06-2012, 11:04 AM   PM User | #18
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,036
Thanks: 197
Thanked 2,411 Times in 2,389 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
You seem to have got your knickers in a twist. It was a simple enough question. Surely what the OP is looking for was (as xelawho has said)

Code:
<script type="text/javascript">

var fullname = "";  // fullname declared outside the function is a global variable
function Bold_Name(which) {
fullname = "<b>";
fullname += which;
fullname += "</b>";
return fullname;
}

alert (Bold_Name("Philip"));
</script>
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Old 10-06-2012, 05:03 PM   PM User | #19
xelawho
Senior Coder

 
xelawho's Avatar
 
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 454 Times in 452 Posts
xelawho will become famous soon enoughxelawho will become famous soon enough
oh, my. I'm beginning to see another reason why we shouldn't be doing homework questions. From the instructions:

Quote:
Do not ... initialize fullname, it will be done for you.
so this:
Code:
var fullname = "";
will wipe out the value of the established variable. ie, FAIL

there's nothing about Bold_Name accepting an argument, so this:
Code:
function Bold_Name(which)
will also naturally FAIL

the simplest answer I can see here is

Code:
function Bold_Name() {
return "<b>"+fullname+"</b>";
}
slightly fancier being

Code:
function Bold_Name() {
var str = "<b>";
str += fullname;
str += "</b>";
return str;
}
xelawho is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:36 PM.


Advertisement
Log in to turn off these ads.