Skip to content

Instantly share code, notes, and snippets.

@jamesdabbs
Created September 30, 2016 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jamesdabbs/8aa4c799e2a6575cf4bc63c87055dc6e to your computer and use it in GitHub Desktop.
Save jamesdabbs/8aa4c799e2a6575cf4bc63c87055dc6e to your computer and use it in GitHub Desktop.
JavaScript explorations
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.1.1.slim.js" integrity="sha256-5i/mQ300M779N2OVDrl16lbohwXNUdzL/R2aVUXyXWA=" crossorigin="anonymous"></script>
<script src="people.js"></script>
</head>
<body>
<button id="asdf">Click Me!</button>
</body>
</html>
console.log("here");
// console.log(test);
// var test = 3;
// floop(3,3);
var z = 10;
var p = {
first: "Su",
last: "Kim",
id: 5
};
p.other = "stuff";
p["test"] = "thing";
console.log(p);
console.log('id is', p.id );
console.log('or also', p["id"]);
var field = "first";
console.log("name", p[field]);
function floop(x,y) {
var z = x + (2 * y);
// z = x + (2 * y);
console.log('z is', z);
return z * z;
}
var out = floop(2,1);
floop(3,3);
floop(1,1);
console.log('out is', out);
console.log('z is', z);
// floop(2,1);
// floop();
// floop(2,1,3,4,5,6,7,8);
var people = [
{
id: 1,
first: "James",
last: "Dabbs"
},
{
id: 17,
first: "Su",
last: "Kim"
},
{
id: 4,
first: "Russel",
last: "Osborne"
}
];
console.log(people);
function printPerson(x) {
var text = x.id + ") ";
text += x.first + " " + x.last;
console.log(text);
}
function printPeople() {
// console.log("here", people);
// for (var i = 0; i < people.length; i++) { ... }
people.forEach(printPerson);
}
// $(function() { "..." })
$(document).ready(function() {
console.log("ready");
$("#asdf").click(printPeople);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment