JavaScript Introduction
Tags: javascript, beginners, tutorial
Published: 2021-08-25 23:52:43

An introduction to _JavaScript_ for those of you who are new to the __Javascript__ _programming_ _language_ or just _programming_. You will need to learn how computers use _programmatic_ approach __ problem-solving__ to achieve goals. By the end of this article, you will know how __Javascript__ is used on the __WEB__ and what capabilities it has. 

This is a series in the making, so please feel free to give feedback, error corrections, etc. I would love this to be a Free Path for self-taught developers and provide as many resources and valuable information as possible. 

We can accomplish many things with __Javascript__ on the web, but what exactly is it?

## How do we use Javascript on the web?

Here is a quick list of what it can accomplish when working with the web.

1. Access Content
2. Modify Content
3. Program Rules
4. React To Event

<img width="100%" src="https://html-css-js.com/images/og.jpg" />

It’s okay if you don’t understand what is going on at first but just know that __Javascript__ allows us to make web pages come to life with these steps.

### What is a Script? 

![Form Component Example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ybttqum8jnxrnkrln5jg.jpeg)


> A Script is a series of instructions

This may seem very simple because, in fact, it is that simple. __Javascript__ is simply a _series_ of instructions by the _computer_ to achieve a goal. For example, when it comes to things other than computers like __Handbooks__, __Recipes__, and __Manuals__, they all have something in common, and it’s following a set of steps to achieve a goal. 

<img width="100%" src="https://www.conceptdraw.com/How-To-Guide/picture/Food-and-Beverage-Cooking-Recipes-Canadian-Apple-Pie-Recipe.png" />

Recipes give folks a set of instructions to follow to create a dish they have never made before. This can be considered a _script_ since it’s simple steps for a meal. Some recipes may seem very basic and quick to make; others may have complex steps and more extended preparation. So if you’re a new __COOK__, then there is a lot of __*terminology*__ to learn. The same concept can be looked at as a programmer.  

<img width="100%" src="https://venngage-wordpress.s3.amazonaws.com/uploads/2019/09/employee-handbook-example-booklet.jpg" />

Companies often provide handbooks to _New_ employees to familiarize themselves with the work environment guidelines. For example, steps for a fire emergency exit if a fire were to go off or some steps that need to be followed within a specific event. I’m sure you get the picture for Manuals as well. 


### How do we create a script?

When writing a __*script*__, we need a few things to keep in mind to make sure we write an excellent __*script*__. 

1. Define the goal 
2. Design the script
3. Code each step

> As tempting as it can be to start coding right away, it pays to spend time designing your script before writing it. 


Computers, unfortunately, need us to tell them how to solve problems. It may seem crazy because we’re so used to programs doing things for us without thinking that now we have to step out of our comfort zone and start thinking like a computer to achieve what we are trying to accomplish with our script. This is where you become different from most developers who simply copy and paste without knowing what the script is doing. For example, when first learning how to ride a bike, you were scared to fall, but once you realized it wasn’t that scary to fall when learning to balance yourself, you knew by starting off with small tasks. 

__*GOAL*__: To be able to ride the bike without falling off.

__*Design Script*__:

1. Training wheels to help balance and get used to turning the handles
2. Remove training wheels and learn to ride as someone is there beside you to help you not fall
3. Stepping off a ledge or step to start riding and get a feel for yourself
4. If you keep on falling and feel like going nowhere, repeat steps one through 3. 
5. Should be able to balance all on your own now and ride freely. (Don’t forget to wear your helmet and safety pads.   
 
__*Code Each Step*__ 

In this example, we would just start riding our bikes and follow the steps as instructed. I might not have the steps correctly, but we have an idea of how to get better at riding a bike with these steps (script). 


In __*Javascript*__ terms, this can be a __Calculator__ App when developing the _addition function_. 

__*GOAL*__: Add up numbers for a new value

__*Design Script*__:

1. Ask the user for two numbers
2. Add numbers up together
3. Return the new number
 

__*Code Each Step*__

Create add function
`function add(){}`

Pass in arguments to act as our numbers that the user passes
`function add(a, b) {}`

Return summed up numbers
`function add(a, b) { return a + b }`

It’s good to know that again __computers__ don’t learn how to perform tasks like you and I. It needs to follow instructions every time it performs its duties. Important things to note when learning a new programming language. 

__*Vocabulary*__: The words that computers understand

__*Syntax*__: How you put those words together to create instructions computers can follow.


## Conclusion 

So what is a script, and how do I create one?

> A script is a series of instructions that the computer can follow to achieve a goal


> Computers approach tasks in a different way than humans, so your instructions must let the computer solve the task programmatically


> To approach writing a script, break down your goal into a series of tasks and then work out each step needed to complete that task

I hope by the end of this article you managed to learn something new. It is crucial to understand how your code works. Not only does it help you become a better developer, but it can also help you use the tools you are working with more efficiently.

These articles are primarily intended for personal use on becoming a better programmer, writer and grow my programming skills. Feel free to drop any feedback or corrections that you believe should be made to help me and others. Thank you for your time for sticking this far!

Follow me on [Twitter](https://twitter.com/CleverOscarDev) for any future article suggestions you’d like to see.