Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,147,897 members, 7,798,993 topics. Date: Tuesday, 16 April 2024 at 01:34 PM

Help Needed . New To Programming Js - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Help Needed . New To Programming Js (1158 Views)

CS50P: Harvad University's Introduction To Programming With Python / My Journey To Programming / Are You New To Programming? Want To Learn But Do Not Know How? Come In! (2) (3) (4)

(1) (Reply) (Go Down)

Help Needed . New To Programming Js by umbawo(m): 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(m): 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)

AFTER LEARNING HTML, WHAT NEXT? / Software Developer Wanted / A Question About String In C++

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 17
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.