Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to name a javascript variable

	//variables can include any letter, any number, or the underscore
	//NO SPACES!!! USE UNDERSCORES!!!
	//variable names are case sensitive
	//example:
var change_this = 'whatever you want here'
	//change_this is a variable (change it to your variable name)
	//'whatever you want here' is a string (you'll learn about this later)
	
Comment

variable name as a string in Javascript function

var a = [1, 3, 4, 3]
var b = [1, 5, 6, 7]
var c = [3, 4, 8, 9]

function arraySum(x, varName) {
    var sum = 0
    for (let i = 0; i < x.length; i++) {
        sum += x[i]
    }
    console.log("sum of " + varName + " is " + sum)
}

arraySum(a, "a");
Comment

PREVIOUS NEXT
Code Example
Javascript :: angularjs select placeholder 
Javascript :: create responsive navbar without javascript 
Javascript :: javascript fadeout without jquery 
Javascript :: express get port from request 
Javascript :: ajax form submit 
Javascript :: hide checkbox jquery 
Javascript :: lottie npm 
Javascript :: js infinite loop 
Javascript :: how to display message in javascript 
Javascript :: upload file in node 
Javascript :: moment-recur cdn 
Javascript :: double click react 
Javascript :: min in array 
Javascript :: pattern printing in javascript 
Javascript :: trigger jquery autocomplete on click 
Javascript :: chart js clear out chart 
Javascript :: how to interrupt scroll with jquery 
Javascript :: reverse array recursion javascript 
Javascript :: How to write a mutation observer js 
Javascript :: top bar in react js 
Javascript :: convert datetime value to time only in reactjs 
Javascript :: express fingerprint 
Javascript :: function l(){return window.performance 
Javascript :: js no new line console.log 
Python :: print red in python 
Python :: python get file size in mb 
Python :: disable images selenium python 
Python :: torch device 
Python :: install django rest framework 
Python :: sorting by column in pandas 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =