₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,327,144 members, 8,429,518 topics. Date: Friday, 19 June 2026 at 03:57 AM

Toggle theme

Help Needed . New To Programming Js - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingHelp Needed . New To Programming Js (1334 Views)

1 Reply (Go Down)

Help Needed . New To Programming Js by umbawo(op): 4:27pm On Oct 08, 2017
I got this as my first programming ! assignment .


My name is

(add your name from two variables where you have stored your first name and last name)

Is my name longer than Tony`s

(make a if statment that check if the length of you name is longer than mine)
Re: Help Needed . New To Programming Js by excanny: 5:06pm On Oct 08, 2017
<script>
var firstName = "John"; // First name
var lastName = "Doe"; // Last name



//concanate(add) both names
var myFullName = firstName + lastName;



//Store Tony's name in variable
var tonysName = "Tony";




// Compare the length of your name vs Tony's

if(myFullName.length > tonysName.length)
{
document.write("My name is longer than Tony's);
}
else
if(myFullName.length == tonysName.length)
{
document.write("Both names are equal in length" );
}
else
{
document.write("My name is shorter than Tony's" );
}

</script>
Re: Help Needed . New To Programming Js by nsimageorge(m): 5:40pm On Oct 08, 2017
excanny:
<script>
var firstName = "John"; // First name
var lastName = "Doe"; // Last name



//concanate(add) both names
var myFullName = firstName + lastName;



//Store Tony's name in variable
var tonysName = "Tony";




// Compare the length of your name vs Tony's

if(myFullName.length > tonysName.length)
{
document.write("My name is longer than Tony's);
}
else
if(myFullName.length == tonysName.length)
{
document.write("Both names are equal in length" );
}
else
{
document.write("My name is shorter than Tony's" );
}

</script>
I think it would be more appropriate to use console.log rather than document.write. Its a JS assignment not a Web assignment.

var firstName = "John"; // First name
var lastName = "Doe"; // Last name
//concanate(add) both names
var myFullName = firstName + lastName;
//Store Tony's name in variable
var tonysName = "Tony";
// Compare the length of your name vs Tony's
if(myFullName.length > tonysName.length)
{
console.log("My name is longer than Tony's" );
}
else
if(myFullName.length == tonysName.length)
{
console.log("Both names are equal in length" );
}
else
{
console.log("My name is shorter than Tony's" );
}
Re: Help Needed . New To Programming Js by umbawo(op): 5:41pm On Oct 08, 2017
u guys are awesome..Thx
Re: Help Needed . New To Programming Js by beatsbyj2g(m): 11:16am On Oct 09, 2017
umbawo:
I got this as my first programming ! assignment .


My name is

(add your name from two variables where you have stored your first name and last name)

Is my name longer than Tony`s

(make a if statment that check if the length of you name is longer than mine)
var names ={}; //declare names object
names.first = 'john'; //define first name value
names.last = 'doe'; //define last name value
names.full = 'My name is'+names.first+" "+names.last; // fomart names
var reply = names.full; //store reply
document.write(reply); //do reply
Re: Help Needed . New To Programming Js by LordeCalifornia: 5:09pm On Oct 09, 2017
excanny:
<script>
var firstName = "John"; // First name
var lastName = "Doe"; // Last name



//concanate(add) both names
var myFullName = firstName + lastName;



//Store Tony's name in variable
var tonysName = "Tony";




// Compare the length of your name vs Tony's

if(myFullName.length > tonysName.length)
{
document.write("My name is longer than Tony's);
}
else
if(myFullName.length == tonysName.length)
{
document.write("Both names are equal in length" );
}
else
{
document.write("My name is shorter than Tony's" );
}

</script>
Nice. How can one run this?
Or more appropriately, how can a layman (like me) appreciate the beauty of the codes you have up there?
Re: Help Needed . New To Programming Js by excanny: 6:54pm On Oct 09, 2017
LordeCalifornia:
Nice. How can one run this?
Or more appropriately, how can a layman (like me) appreciate the beauty of the codes you have up there?
Run it on any web browser of choice inside a html file.
Re: Help Needed . New To Programming Js by LordeCalifornia: 7:01pm On Oct 09, 2017
excanny:
Run it on any web browser of choice inside a html file.
What do you mean by "inside a HTML file" ?
Re: Help Needed . New To Programming Js by excanny: 7:03pm On Oct 09, 2017
LordeCalifornia:
What do you mean by "inside a HTML file" ?
The script needs "flesh" to run. This "flesh" is an HTML file.
Re: Help Needed . New To Programming Js by LordeCalifornia: 7:07pm On Oct 09, 2017
excanny:
The script needs "flesh" to run. This "flesh" is an HTML file.
Now I'm confused smiley I'm actually new to this.
Don't be offended, how do I get the HTML file?
I just want to appreciate the beauty of coding.
Re: Help Needed . New To Programming Js by excanny: 7:14pm On Oct 09, 2017
LordeCalifornia:
Now I'm confused smiley I'm actually new to this. Don't be offended, how do I get the HTML file? I just want to appreciate the beauty of coding.
Go learn here www.w3schools.com
Re: Help Needed . New To Programming Js by LordeCalifornia: 9:14pm On Oct 09, 2017
excanny:
Go learn here www.w3schools.com
This is nice. Thanks.
1 Reply

CS50P: Harvad University's Introduction To Programming With PythonMy Journey To ProgrammingAre You New To Programming? Want To Learn But Do Not Know How? Come In!234

Please, Help Solve The Problem Of Appearing Ending Line \r\nBuilding An Hierarchical Comment System In Asp.net Mvc, Ms Sql Server, CssJava Developer Required For Mifos X Customisation