Coggle requires JavaScript to display documents.
function add (){ var a = 1; var b = 2; var c = a+b; console.log(c) }
function add (a,b){ var c = a+b console.log(c) }
var user = {};
var house2 = {}; house2.rooms = 4; house2.color = "pink"; house2.priceUSD = 12345; console.log(house2); // {rooms: 3, color: "brown", priceUSD: 10000}
var house2 = {}; house2["rooms"] = 4; house2['color']= "pink"; house2["priceUSD"] = 12345; console.log(house2); // {rooms: 4, color: 'pink', priceUSD: 12345}
var car = {}; car.color = "red"; car["color"] = "green"; car["speed"] = 200; car.speed = 100; console.log(car); // {color: "green", speed: 100} car["number of doors"] = 4; console.log(car); // {color: 'green', speed: 100, number of doors: 5}
car["2022"] = 1901; console.log(car); // {2022: 1901, color: 'green', speed: 100, number of doors: 5}
var arrOfKeys = ['speed', 'altitude', 'color']; var drone = { speed: 100, altitude: 200, color: "red" } for (var i = 0; i < arrOfKeys.length; i++) { console.log(drone[arrOfKeys[i]]) }
var assistantManager = { rangeTilesPerTurn: 3, socialSkills: 30, streetSmarts: 30, health: 40, specialAbility: "young and ambitious", greeting: "Let's make some money" }
[1,2,3]
var fruits = []; fruits.push("apple"); // ['apple'] fruits.push('pear'); // ['apple', 'pear']
try{ things happened an may be couse err }catch{ if there an err there will be a statement for there and another aaction maybe} }
throw new ReferenceError("error!")
function listArrayItems(arr) { for (var i = 0; i < arr.length; i++) { if (arr[i] == 'red') { console.log(i*100, "tomato!") } else { console.log(i*100, arr[i]) } } }
0 'tomato!' 100 'orange' 200 'yellow' 300 'green' 400 'blue' 500 'purple' 600 'pink'
fruits.pop(); console.log(fruits); // ['apple']