Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philippeschneide/0f700a34aa03ccc10d15227c7720818a to your computer and use it in GitHub Desktop.
Save philippeschneide/0f700a34aa03ccc10d15227c7720818a to your computer and use it in GitHub Desktop.
Code From the Developer Tools Crash Course
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="style.css">
<title>Devtools Test</title>
</head>
<body>
<h1>Hello World</h1>
<button>Button</button>
</body>
<script>
// console.log('Hello');
// //console.log(myvar);
// console.error('An error');
// console.warn('A warning');
// console.dir(document);
// console.table([{name:'John', email:'test@test.com', age:33}]);
// console.clear();
// console.group('Say Hello');
// console.log('Hello Brad');
// console.log('Hello John');
// console.log('Hello Sally');
// console.groupEnd('Say Hello');
// console.time('Run Loop');
// for (var i = 0; i < 20000; i++) {
// console.log(i);
// };
// console.timeEnd('Run Loop');
// function greaterThan(a,b) {
// console.assert(a > b, {"message":"a is not greater than b","a":a,"b":b});
// }
// greaterThan(5,6);
// document.querySelector('button').addEventListener('click', loadUsers);
// // Load Github Users
// function loadUsers(){
// var xhr = new XMLHttpRequest();
// xhr.open('GET', 'https://api.github.com/users', true);
// xhr.onload = function(){
// if(this.status == 200){
// var users = JSON.parse(this.responseText);
// var output = '';
// for(var i in users){
// output +=
// '<div class="user">' +
// '<img src="'+users[i].avatar_url+'" width="70" height="70">' +
// '<ul>' +
// '<li>ID: '+users[i].id+'</li>' +
// '<li>Login: '+users[i].login+'</li>' +
// '</ul>' +
// '</div>';
// }
// document.getElementById('users').innerHTML = output;
// }
// }
// xhr.send();
// }
// Set localstorage - will stay until delete/clear
localStorage.setItem('name','John');
// Set sessionstorage - will stay until browser close
sessionStorage.setItem('user', 'Will');
// Set cookie
document.cookie = "username=John Doe";
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment