Help Needed . New To Programming Js - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Help Needed . New To Programming Js (1336 Views)
| 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: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: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. |
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
Pls I need help in python or java • I Need A Software Or App Developer • Python Q|A Ask Any Question?? || Or Drop A Python Tip...
I'm actually new to this.