var array = [1,2,3,4,5,6,7,8,9,10]
var brray = ["one","two","three","four","five","six","seven","eight","nine","ten"]
for( i = 0 ; i < array.length ; i++){
console.log(array[i], brray[i])
Category: print
how to print an element in javascript
console.log("")
console.log("Who's Joe?")
//How to print a specific element in javascript
/*====DESCRIPTION starts here=====
You can output a specific element or position of a list/array by
using the output statement which is console.log(). Within it, type in the
name of the array in which you are dealing with, and specify with brackets
after the array name, enter the number of the
position you want to output. Note though that as computers
count beginning from 0, you will have to subtract
1 from the original position we percieve.
====DESRCIPTION ends here=======*/
//====EXAMPLE 1 STARTS HERE=========
//Using an integer to output a specific element/position of an array.
//array named "arr" which consists of 4 elements which are integers.
var arr = [3,4,5,2]
console.log(arr[2]) //Outputs "5" because 5 is the second (or third) element of the array.
//====EXAMPLE 1 ENDS HERE=========
//====EXAMPLE 2 STARTS==========
//Using a variable to output a specific element/position of an array.
//array named "arr" which consists of 4 elements which are integers.
var arr = [8,9,3,5]
//A variable named "i" which stores a value of an integer, 2.
//Will be used to output the second element of the array.
var x = 0
console.log(arr[x]) //Outputs "8" since 8 is the 0 (or first) elemnt of the arary.
//====EXAMPLE 2 ENDS HERE==========
how to print array backwards
var array = ['a','b','c','d','e','f','g']
var j = array.length
for(var i = 0; i < array.length ; i++){
console.log(array[j])
j=j-1 }
/*
var j holds value of the array's number of values so every time in the loop it decrements by 1 making the
function print a backwars array
*/
how to print console in javascript
console.log("message here")
how to print date like 10-may-2018 in javascript
date.toString('YYYY-MM-dd'); 'Tue Feb 10 2015 15:42:50'
var date = new Date('4-1-2015');
date.getDay();// returns 3
date.getYear();// returns 115, no of years after 1900
date.getFullYear();// returns 2015
date.getMonth();// returns 3, starting 0 with jan
date.getUTCDate();// returns 31
how to print diamond pattern in javascript
<script type="text/javascript">
for(var i=1;i<=5;i++)
{
for(var j=1;j<=i;j++)
{
console.log("*");
}
console.log("n");
}
</script>
how to print in jsp
out.print("Print")
how to print NODE_PATH
if (!process.env.NODE_PATH) {
console.log();
if (process.env.SHELL === '/bin/zsh') {
console.log(' Please set environment variable NODE_PATH in ~/.zshrc:');
} else if (process.env.SHELL === '/bin/bash') {
console.log(' Please set environment variable NODE_PATH in ~/.bashrc:');
} else {
console.log(' Please set environment variable NODE_PATH:');
}
console.log();
var nodepath = __dirname.replace(/(/|\)nico(/|\)bin$/, '');
if (/node_modules$/.test(nodepath) && !fs.existsSync(path.join(nodepath, '.bin'))) {
if (os.platform() === 'win32') {
console.log(' NODE_PATH=' + nodepath);
} else {
console.log(' export NODE_PATH=' + nodepath);
}
}
console.log();
process.exit();
}
how to print numbers in javascript
for (var i = 1; i <= 100; i++) {
console.log(i);
}
//the boolean or the second term in the for statement
//which in this case is i <= 100 makes the console print
// numbers 1-100
//KEY: REPLACE !)) WITH THE NUMBER U WANT IT TO GO UNTIL
how to print the value of variable in javascript in html
var name="kieran";
document.getElementById("output").innerHTML=name;
and the html code would be:
<p id="output"></p>