Weekly questions to consider when creating your posts. These questions are a jumping off point to asking your own questions, pose new ideas, and provide explanations and examples backed by careful analysis. Apply class concepts, terms, and theories too. Refer to Assignment 12 for additional details.
- What is a variable in JavaScript, and how do you create one?
- How do you initialize a variable?
- What is the difference between initialized and declared?
- What are the rules associated with naming a variable?
- What are the arithmetic operators in JavaScript, and what do they all do?
- What is concatenation, and what are the concatenation operators?
- What is the line of code used to prompt a user for a response?
Jinzhou Situ says
Threat modeling refers to the method of finding potential threats in the system and then establishing countermeasures. In order to establish a secure system, there are three common threat modeling methods: Attacker-centric, Software-centric, and Asset-centric. The General Data Protection Regulation (GDPR), the Health Insurance Portability and Accountability Act (HIPAA) and the California Consumer Privacy Act (CCPA) all involve some important regulations for data protection. If these security regulations are not complied with, Offenders could face substantial fines or imprisonment. Ransomware refers to invading the victim’s computer through a Trojan horse virus, and intimidating the victim under the guise of law enforcement agencies. Hospitals are often attacked because they store a lot of valuable personal information of patients in order to save lives. This information will become the weakness of patients and hospitals, making it easy for hackers to submit. Many antivirus software and online security tools can prevent users from accessing some virus-infected websites and protect users’ computer security. The three types of artificial intelligence are artificial narrow intelligence (ANI), artificial general intelligence (AGI) and artificial superintelligence (ASI), which can only perform some single tasks, such as facial recognition and voice assistants. General artificial intelligence can imitate human thinking mode, for example, some supercomputers have come very close to this goal. Artificial superintelligence refers to AI that surpasses human intelligence, which has not yet been realized and only exists in human fantasy. Alan Turing is the father of computers, during World War II, he developed a machine specially used to decipher German codes, enabling the Allies to decipher a large number of German telegrams. The purpose of the Turing test is to test whether a machine can have the same intelligence as a human being, which was proposed by Turing in 1950.
Montajim Khan says
For example, Javascript variables are data storage: an “An online shop- the information includes good being and a shopping card.” or “a chat application- the information might include users, messages.” I assume to initialize a variable, you would use “=” when you’re writing a script. This would help the computer understand what your trying to calculate. Without it, the computer would be clueless. Initializing is a process that assigns a value to a variable, but if it a value isn’t assigned to anything, it would be called a declaration. One lesson I learned during javascript was its case sensitivity. Also, letters and signs are important and should be careful. Arithmetic operators are operators signs such as add, subtract, multiply, division, modulus, and many more. One thing that stood out during class was, “if the string looks like a number, javascript will convert the string to a number to do arithmetic.” Concatenation connecting strings together such as using “()” and “+” Lastly the line of code used to prompt a user for a response is “prompt()”
https://javascript.info/variables#:~:text=A%20variable&text=We%20can%20use%20variables%20to,JavaScript%2C%20use%20the%20let%20keyword.&text=To%20be%20concise%2C%20we%20can,(message)%3B%20%2F%2F%20Hello!
https://www.scaler.com/topics/string-concatenation-javascript/
Sheree Owens says
Hi Montajim! These are great examples and resources you shared to get a better understanding of Javascript variables and string concatenation. I think highlighting what we learned during the class and how the code will be interpreted by our computer is important. Learning the purpose that string concatenation merging two or more things together and when to use it will help when coding.
Assia Snineh says
Hey Montajim,
This was a great explanation about Javascript. You provided great examples and resources and explained the use of Javascript very well!!
Madeline Elia says
A variable is an identifier for a value. The most common way that variables are used is with the “let” keyword, followed by the name of the variable. An example of this would be: let myText . When the variable has a name, but does not have a value, it is what’s known as declared. It should be given a value, though, so that it serves a purpose. This process is known as initializing the variable. To initialize the variable, you use an equals sign (known as the “assignment” operator) to assign the variable to the contents of the value. For example: let myText = “Good morning!”; . In addition, you should use quotation marks around the contents of the value. Declaring and initializing variables are very important steps in coding, but they also have their differences. Declaring a variable is giving it a name, and initializing it is giving it a value.
Montajim Khan says
Hi Madeline,
I like how you described the keyword “let,” the most commonly used variable for variables. An example helped me understand what a variable is and what it does. Also, the process of “declared” and “initializing” made things easier for me to understand what the two differences.
Levan Lobjanidze says
Thanks for the post. Reading about someone’s explanation, a different perspective, helps to better understand JavaScript.
Anthony Marquis says
Hi Madeline, you described the “let” keyword very descriptively and thought that your post helped me have a better understanding about JavaScript as a whole.
Isel Sainte says
This week was a difficult one because we were learning JavaScript and I knew nothing about it. This is more of my sister’s thing. She is a Graphic Designer. Anyway, variables are identifiers. Identifiers of data being entered. We create a variable by using the keyword let and after typing the name we came up with for the variable. This is how we declare a variable let yourname. This is how we initialize a variable let yourname= “Isel Sainte”; When naming a variable, the length does not matter, it can start with a letter/underscore/dollar sign, you can mix and match lowercase and uppercase letters, a number is not allowed, spaces are also not allowed.
Here is what arithmetic operators in JavaScript, and what they all do:
+ it adds
– it subtracts
* it multiples
/ it divides but this result is a floating-point number
% it divides but this result gives the remainder
Order of operation is important when using the arithmetic operators.
Justin Bonfiglio says
Hey Isel,
I completely agree that its been difficult learning about and doing all of the coding work, but it has also been a lot of fun. Also I feel like any field of business could use at least a little bit of knowledge on how this works, especially if you want to one day run your own business! Also I wanted to add on the topic of naming variables that you can make the name as long as you want, but most higher level coders all like to run a system with the lowest amount of characters to make it as easy as possible. I’ve talked with my friends before who work with coding and they say that some of the variables are just 1-2 characters long to make it as quick and easy as possible.
Aidan Morgan says
Hi Isel, as someone who was previously a Computer Science major, I can totally see where you are coming from when saying getting introduced to coding is challenging. Any time I would learn a new language it would be very confusing for me and I still even struggle with certain aspects of coding. I agree that learning code can be and is difficult at times, but the satisfaction of completing a code correctly is great.
Robert DiBrino says
Hi Isel! I really appreciated your honesty about this week being a difficult one. I absolutely came in thinking the same thing, but learning the operators and taking my time to learn the other material really helped me to comprehend it better. Even though I will not be going into the computer science field, I have a great appreciation for JavaScript now and will be able to have a small understanding of what my coworkers do.
Nicholas DiGiuseppe says
Hi Isel,
Great job at explaining the key operators in JavaScript. After getting introduced to JavaScript in this class, I can definitely say that I truly appreciate JavaScript for what it is and also with what we have learned even though there is still plenty more to learn if I want to ever get truly good at using it. It is definitely something I can keep in the back of my mind for sure.
Justin Bonfiglio says
A variable in JavaScript is also known as and identifier is used to store data in a line of code. Usually when creating a variable you use the “let” keyword with the variable such as the myText example we did in class. Within these variables you can either initialize or have it declared. Initialized assigning the initial value for each variable while declared will declare the start or formation of variables. Two main rules when naming variables are that variables must start with a letter or underscore and must contain only alpha-numeric characters (a-z, A-Z, 0-9, and _).
Another feature of JavaScript are arithmetic operators that use number that you input and do math or calculate them. We used this in class towards the end when we set up a page that will add the taxes onto any number we entered automatically. We used the prompt () method to allow the users to enter whatever they wanted, and the computer do the work for us.
In terms of JavaScript, a concatenation is when you add strings to the end of another to make a long chain of code. We used concatenation operators in class with the example of simplifying the math from multiple different codes into one line that did the same thing with less than half the space and effort.
Sophie Chen says
Hi Justin,
I think you did a really clear and concise job of explain the basics of JavaScript and JS syntax. I liked that you referenced the example we did in class; it reminded me when and where we practiced JS arithmetic operators. I agree that concatenation operators can make our code more efficient with less space, and I think practicing concatenation can be very useful for the future.
Madeline Elia says
Hi Justin,
I like your point about using prompts. Rather than having data in the code itself, prompts allow the user to type in their own data. Once the data is entered, the computer will do the work. Although prompts are a great tool, some issues can occur due to concatenation and the fact that strings are the default return. This means that numbers added will literally be combined (for example: 2+2=22) instead of the right answer. Using parseInt() and parseFloat() will convert and solve problems correctly.
Assia Snineh says
HI Justin,
I think you did a great job explaining javascript and the use of it and how resourceful it is!
Sophie Chen says
A variable in JavaScript is simply a name of storage location to hold values. A variable can be a string of characters, a string of numbers, just numbers, or a mix of both. To create a variable, you must put “var” in front of the variable name with valid variable syntax. An initialized variable is created with a value while declared variables are just created with no assigned value. Variables can contain letters, digits, underscores, and dollar signs, but they must start with a letter, dollar sign, or an underscore. Variables are case sensitive. You can refer to variables in a separate string, but they do not do into the string quotations; instead, they are separated by a “+” in between string text.
JavaScript can do a variety of mathematical operations: addition, subtraction, division, modulus. You can compute addition and subtraction using “+” and “-“, and you can compute multiplication and division using “*” and “/”. Modulus is computed by dividing the first number by the second number and then saving the remainder; it’s computed using “%”.
I think learning JavaScript has been very interesting because it’s cool to see how easy it is to code simple commands, and the results are immediate. Seeing the backend of how my favorite websites work unlocks a lot of the mystery behind the web and different websites, and can also be useful if I want to create my own website one day.
Isel Sainte says
I remembered seeing var when completing the JavaScript Assignment and had to go back to it to see what we used it for. It is the same as let but just an old version. Keep in mind in class Professor Sclarlow explained we will be using let. Just mentioned for when he gives us an exam you pick the one, he wants us to use.
Cassidy Mantle says
Hi Sophie,
I enjoyed reading your response. As I definitely described each sequence and function similarly. Javascript for me was difficult to adjust to at first and I actually remember when it was initially introduced because I had a few technical difficulties when first trying to figure out how to use the software but like anything, practice makes perfect so I took a few failed attempts to master the usage at the end which resulted in me overcoming my coding discrepancies and actually finding few detects in my coding blocks.
Sheree Owens says
In JavaScript, arithmetic operators take numerical values (either literals or variables) as their operands and return a single numerical value. There are four standard arithmetic operators, addition (+), subtraction (-), multiplication (*), and division (/).
These operators work as they do in other programming languages except the division (/) operator which returns a floating-point division in JavaScript, not a truncated division as it does in languages such as C or Java.
For example:
1/2 returns 0.5 in JavaScript.
1/2 returns 0 in Java.
In addition, JavaScript provides modules(%), increment(++), decrement(–) and unary negation(-) operators.
Operator Name Purpose Example
+ Addition Adds two numbers together. 6 + 9
– Subtraction Subtracts the right number from the left. 20 – 15
* Multiplication Multiplies two numbers together. 3 * 7
/ Division Divides the left number by the right. 10 / 5
% Remainder (sometimes called modulo)
Returns the remainder left over after you’ve divided the left number into a
number of integer portions equal to the right number.
8 % 3 (returns 2, as three goes into 8 twice, leaving 2 left over).
** Exponent Raises a base number to the exponent power, that is, the base number
multiplied by itself, exponent times. 5 ** 2 (returns 25, which is the same as 5 * 5).
Isel Sainte says
I like how you pointed out the difference between Java and JavaScript when it comes to division. I also liked how well you explained the remainder and included an example. It helped me get a visual of both of these operations.
Jinzhou Situ says
Hi, Sheree.
I like the demo formula you showed about javascript, it gave me an intuitive understanding of its workflow. In fact, it works very similar to mathematical calculations, but uses the principle of binary.
Cassidy Mantle says
Hi Sheree,
Your response has been extremely helpful in understanding the operator purposes. Apart from that, it is nice to see how you included everything in a learners format which basically means the format you chose to use was way easier to interpret then others in a sense where you decided to list and label everything and its corresponding elements. Personally I chose to write everything in a general overview, but this definitely exemplifies your understanding of the subject and I enjoyed reviewing the symbols and operator purposes.
Shivam Joshi says
A variable in JavaScript is a container that holds a value, which can be a number, string, object, or any other data type. To create a variable, you can use the “let”, “const”, or “var” keyword, followed by the name of the variable. For example, to create a variable called “myVariable”, you can write “let myVariable;”. To initialize a variable, you can assign it a value using the assignment operator “=”. For instance, to initialize “myVariable” to a string value, you can write “myVariable = ‘Hello World’;”. The difference between declaring and initializing a variable is that declaring a variable means creating a reference to it, while initializing means assigning a value to the variable. When naming a variable, it must start with a letter, underscore, or dollar sign and cannot include spaces or special characters. JavaScript provides various arithmetic operators, including addition (+), subtraction (-), multiplication (*), division (/), modulus (%), increment (++), and decrement (–), to perform mathematical operations on variables. Concatenation is the process of combining two or more strings into one. JavaScript provides concatenation operators, such as the plus sign (+) and the “+=” operator, to concatenate strings. The line of code used to prompt a user for a response is “prompt(‘Enter your name:’);”.
Levan Lobjanidze says
A variable in JavaScript stores a value, which can be a string, number, letters or any other data type. Variables in JavaScript are labeled using the var, let, or const keyword, followed by a name in parentheses.
Once a variable is created, it can be given a value using the assignment operator (=). The value of a variable can be changed or updated at any time during the execution of a JavaScript program. Variables are essential in coding, since they allow developers to store and manage data.
We can create a variable like this example:
let variablename = 7;
Initialization is giving a value to a variable and if there is no value given to a variable it is called that it is declared.
JavaScript can also perform arithmetic operators. For these operations, we can use addition +, subtraction -, multiplication *, division /, remainder %, increment adds 1 to a variable ++.
decrement subtracts 1 from a variable – – ,
In JavaScript we also use concatenation where we connect two string into one.
Ishaan Joshi says
Hello Levan, you did a great job at explaining JavaScript variables and all the minuscule details that go into it. It can certainly be frustrating to remember and apply all these details but the more you do it the better you get at it. It also makes it that much more rewarding when you do it correctly.
Assia Snineh says
A JavaScript variable is nothing more than the name of a storage location. In JavaScript, use the let keyword to declare a variable. An initializer’s syntax is the type, followed by the variable name, followed by an equal sign, followed by an expression. This expression can be anything as long as it is of the same type as the variable. The process of assigning a value to the Variable is known as initialization. Each programming language has a unique method for initializing variables. If no value is assigned to the Variable, the process is referred to as a Declaration. A variable name must begin with a letter or an underscore. A variable name must not begin with a digit. Only alphanumeric characters and underscores are permitted in variable names, variable names are case sensitive. Arithmetic operators in JavaScript take numerical values (either literals or variables) as operands and return a single numerical value. Concatenation operators combine multiple strings into one. Concatenation operators + and & are available. Both perform the fundamental concatenation operation.
Yi-Lun Ma says
Hi Assia,
you have explain the JavaScript very easily to let me understand. You have explain how to use it and I hope you can provide some example. Thank you
Yi-Lun Ma says
A variable in JavaScript is a named storage space that can hold a value, such as a boolean value, text, or number. Programmers can store data in variables to use it later in their code or to update the value as necessary.To create a variable in JavaScript, you need to use one of three keywords: “var”, “let”, or “const”.
Addition (+): adds two or more values together
Subtraction (-): subtracts one value from another
Multiplication (*): multiplies two or more values together
Division (/): divides one value by another
Modulus (%): returns the remainder after division
Increment (++) and Decrement (–): add or subtract 1 from a value
Aidan Morgan says
One way to simplify code in JavaScript is with the use of variables. Variables in JavaScript are storage spaces that hold values and will display those values when the variable is called. The let keyword initiates the use of a variable. While var is an older keyword for using variables, JavaScript would still recognize the use both of var and let when using variables. To use variables, you would start by implementing the let keyword followed by a name for the variable. For instance, a variable could look like let myName. In the example I just gave, the variable has only been declared since it does not contain a value. However, if I wanted to initialize the variable, I could give it a value such as let myName = “Aidan”; Here, the variable as been initialized as it now holds a value. If I wanted to call the variable I would just print alert(myName), which would display the text of “Aidan”. When using variables, there are some rules, or guidelines, to follow. The variable can be any length as long as one character is used, the variable can start with a letter, underscore, or even the $ character, but it cannot start with a number. After the first character, a variable ca of any combination of letters, underscores, numbers, and $ characters. Finally, spaces are not allowed within variables. Arithmetic operators can be used within JavaScript with some operators such as addition (+), subtraction (-), multiplication (*), division (/), and modulus (%). These operators help perform mathematical equations with variables. When using these operators, PEMDAS is applied in terms of the order of operations within JavaScript.
Amgad Elamin says
Hello Aidan,
Using variables can be confusing sometime. variables can be number, character or letters. using different types of variables require using different commands. This computer language is fun to learn.
Nicholas DiGiuseppe says
In JavaScript, we use variables in order to store data in a line of code. The keyword that we use when we want to create variables, is “let.” It is very important to remember that we can only start variables by using either a letter, underscore, or even the $ symbol. Spaces are not allowed at all within variables. When it comes to addition, subtraction, multiplication and division, JavaScript is able to compute any of these operations by simply using the symbols: “+” “-” “*” and “/” respectively. Also, when you want to have an exponent raised to the power of a number, we use two star symbols. For ex: 72 ** 4. Concatenation involves joining two or more strings into one. The operators that JavaScript provides are the plus sign and the plus and equals sign. It is also important to remember that JavaScript also uses the order of operations. It will immediately apply the rule of PEMDAS and the correct number will be computed appropriately.
Lamine Karamoko says
Java script is a coding language that is made for users to interact with websites or games. When you are working with functions, they have a chance of containing arithmetic operators. Arithmetic operators are mathematical operations that are applied to functions, loops or anything else that has to do with Java script. These operators used in PEMDAS are +, -, * or multiplication and / or division. There are other operators that can be used, such as the modulus operator(%). This is used for returning the remainder after the division. Another one is the increment operator or ++. This is used to increase the value of any variable by 1. Lastly, you have the decrement or – -.This is the opposite of the increment operator, as this one is used to decrease the value of any variable by 1. Arithmetic operators could also be used to be placed together in order to change the output of a variable.
Amgad Elamin says
Hello class,
I must start this blog by saying I’m not tech savvy. I use the web like many other people do however I do not know what goes behind my computer screen. In the beginning, it was very difficult and annoying to figure functions loops etcetera. However, the book was very useful. Information was easy to understand and apply. I’ve watched few videos to show me how to use Visual Studios program. I wanted to know how to open files. I wanted to know the different parts of the programming screen. In the past, I found errors that state that JavaScript is not running or not found. I have to admit that after taking few classes I think it is easy but it’s not my cup of tea. I remember in the in-class-activity we used guess the number program. It was fun.
Robert DiBrino says
Comprehending these new terms around coding has certainly been a learning curve for me. Coding and programming is not something I have had experience with in the past. Concatenation? Arithmetic Operators? Outside of coding I don’t know if I would have ever heard these terms. Concatenation was a term that I had a difficult time understanding, but initially hearing the word is a lot scarier than what it means. To fully understand it, you must first learn that a String in Java is. A string is simply a sequence of characters! For example: “Robert” is a string and R O B E R T are the sequence of characters within that string. Once you are familiar with what a string is, you can then move to grasp Concatenation. Simply put, concatenation is joining two strings together. For example: “Robert” (first string) “DiBrino” (second string), when these two strings are joined together, “Robert” + “ DiBrino”, you create a concatenation. To add to that, we have also used the (+) symbol, which is an arithmetic operator. The plus sign is an example of one of the operators that we have covered so far in this course but other operators consist of (-), (/), (*), (%). Taking time to understand the different aspects one by one and how they all work together to create a code, is vital to understanding programming as a whole.
Ishaan Joshi says
In JavaScript, a variable is a named container that helps store data values. It can hold numbers, strings, objects, var, let, and const before the variable’s name, depending on what kind of code you are trying to process. To initialize a variable, you must use the equal (=) sign. For example, “var x = 25”. In a declared variable, you create a variable to store data and assign it a particular name. Initializing a variable is assigning an initial value to a declared variable. In the above example, x is declared with var and is initialized with “25”. Arrhythmic operators are symbols with an operation assigned to each to create mathematical solutions. Examples of this would include the plus sign (+) for addition, the minus sign (-) for subtraction, the forward slash sign (/) for division, or the asterisk sign (*) for multiplication. These are a few of many examples that are vital to solving functions on JavaScript.
Anthony Marquis says
A variable in JavaScript can be described as a named storage for your data and we use variables in order to store goods, visitors, as well as other pieces of data being collected. You can create a variable in JavaScript by using the keyword “let” in order to create a variable. All variables are initialized with the value that is being undefined. Variables are initialized and undefined upon the initialization of their complex environment. The difference between declaration and initialization is; Declaration is when you declare a variable with a name, and a variable can be declared only once, while Initialization is when we put a value in a variable, this happens while we declare a variable. The rule with naming a variable is to start with a capital letter and to exclude underscores. There are four arithmetic operators that include, addition, subtraction, multiplication, and division. All of these operators work as they do in other programming languages. Concatenation are joined in a way that the last character, bit, graphic, or widechar of the operand to the left immediately precedes the first character, bit, graphic, or widechar of the operand to the right, with nothing intervening. Its simple, the prompt method in JavaScript is basically used to display a prompt box
Preston Cain says
A variable in Javascript is the same way as saying you have x in an algebra question you can use x to manipulate the question the same way you use the variable in java script to help you answer the question or complete the task. In Javascript a variable can be “let” or “var” followed by the variable itself in () which declares the variable for you. The restrictions of what you can use for your variable are numbers and spaces as they will cause the program to have an error and your code will not run properly. The point in using variables in javascript is to make the program complete a task for you and the variable itself helps identify that task. Java script has the ability to do arithmetic functions aswell, such as addition, subtraction, multiplication and division.