Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,356 members, 7,954,442 topics. Date: Friday, 20 September 2024 at 07:02 PM |
Nairaland Forum / Science/Technology / Programming / Help Needed . New To Programming Js (1220 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)
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: 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: 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: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: 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: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: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:Now I'm confused 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:Go learn here www.w3schools.com |
Re: Help Needed . New To Programming Js by LordeCalifornia: 9:14pm On Oct 09, 2017 |
excanny:This is nice. Thanks. |
(1) (Reply)
Embedded System And Iot Expert Is Here!!! / Developing A Sport Betting Site From Scratch / 10 Or More Programmers Needed To Co-found A Big Technology Company
(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. 24 |