printf - Can't even print out an array -


i'm trying print out array not working.

currently using sublime text 2 , node build, not sure if have declare before writing code.

here's code:

string card[] = new card[2] card[0] = "ace"; card[1] = "two";  card[3] = "three";    for(int i=0; i< card.length; i++) {     system.out.print(""+card[i]); } 

the debugger gave me following result:

(function (exports, require, module, __filename, __dirname) {   string card[] = new card[2]   syntaxerror: unexpected identifier     @ object.exports.runinthiscontext (vm.js:76:16)     @ module._compile (module.js:542:28)     @ object.module._extensions..js (module.js:579:10)     @ module.load (module.js:487:32)     @ trymoduleload (module.js:446:12)     @ function.module._load (module.js:438:3)     @ module.runmain (module.js:604:10)     @ run (bootstrap_node.js:394:7)     @ startup (bootstrap_node.js:149:9)     @ bootstrap_node.js:509:3 [finished in 0.1s exit code 1] 

looks you're mixing javascript java or language.

javascript doesn't use explicit types in declaration, declare new array write var array = [];

the printing output more java javascript. rather system.out.print use console.log writes standard out. can write standard error console.error

for js example this:

var card = []; // declare variable card array card[0] = "ace"; card[1] = "two";  card[3] = "three";    for(var i=0; i< card.length; i++) {     console.log(card[i]); } 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -