Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9035113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:40:41+00:00 2026-06-16T08:40:41+00:00

I am pretty new to web dev and I have been doing some JavaScript

  • 0

I am pretty new to web dev and I have been doing some JavaScript exercises I found on line. One of them asks to prompt the user for a first and last name and add these names to the document.

In researching this I found code that used a lot of variables. My solution was this:

var el = document.getElementById("welcome");
var txt = fullName;
var node = document.createTextNode(txt);
el.appendChild(node);
    };

greet()

I played around a bit, and found that this worked:

document.getElementById("welcome").appendChild(document.createTextNode(fullName));

You can see my original solution at jsFiddle. I also added the instructions to the HTML.

My question is why do most tuts suggest putting in the variables at all? Is it best practice? Why?

Oh, and if you go there, can someone tell me why my ordered list came out with no numbers? Does jsFiddle use a reset on their CSS?

Note: I’m not sure I needed to put it in a function, but right now, putting everything in a box helps me keep organized.

Thanks for any help
Dave

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T08:40:42+00:00Added an answer on June 16, 2026 at 8:40 am

    It is not that you need to use many variables in your code, it’s just that you are a beginner and often author doesn’t use super programming skills to teach beginner’s, as and when you learn you can make your code stronger, shorter, and much intelligent. So if you are writing a better code while you are studying that’s seems that you are learning much much faster…Using variables to hold values is often a good practice..but ofcourse if you are smart enough to make your work without using much of them is no harm…here’s a simple example where you don’t actually need 2 variables

    var a = 5, b = 5;
    var result = a + b;
    
    alert(result); //Results 10 
    

    could be simply written as

    var total = 5 + 5;
    alert(total); //Results 10 too
    

    But again when going for the second approach you might not be using var total everywhere and you need to change the values yourself everytime you want a result, so better create sufficient variables which will be easier for you to modify your code and use the data accordingly

    And for the other question, yes jsfiddle do resets CSS

    Just uncheck Normalized CSS if you don’t want to reset the elements

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am pretty new to web services and have been trying to implement Soap Faults.
I'm pretty new to web design and have recently been working on an amatuer
I'm pretty new to web development. Lately I have been making a site using
I am pretty new to web dev and thought I needed a 20gb shared
I'm pretty new to Rails and web dev in general. I need to display
I'm pretty new to JWS. I have a web application ( several web services
I'll admit that I'm pretty new web development (only been coding for about a
I'm pretty new to web development and I have an idea for something that
I'm pretty new to the realm of web design, however, I've been having a
I'm still pretty new to asp.net web forms. I have a requirement to make

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.