This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* program for tic-tac-toe game | |
* it starts with a randomly placed X | |
*/ | |
var ticTacToe = { | |
// board layout | |
board: [], | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (var i = 1; i <= 100; i++){ | |
if (i % 15 == 0) { | |
console.log('FizzBuzz') | |
} else if (i % 3 == 0) { | |
console.log('Fizz') | |
} else if (i % 5 == 0) { | |
console.log('Buzz') | |
} else { | |
console.log(i) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = []; | |
a['0'] = 1; // assign value using property name as string | |
// number converted to string and used as property name | |
a[1] = 2; // assign value using property as an integer | |
a[2.0] = 3; // assign value using property as a floating point number | |
console.log(a) // => [1,2,3] | |
console.log(a.length) // => 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// a simple function to display a greeting | |
var sayHello = function() { | |
return alert('Hello there!'); | |
}; | |
sayHello(); // => Hi there! | |
// ---------------------------------------- | |
// function returns an object, text preset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Message #333 | |
{ html: '...', | |
text: '...', | |
headers: | |
{ 'x-apparently-to': '<email_address>@yahoo.com via 98.138.31.140; Thu, 19 Dec 2013 16:50:09 +0000', | |
'return-path': '<t0058a35c69-e0cd9af96-c48313d748aa4f5085b042a35ccd1cdf@bounce.twitter.com>', | |
'received-spf': 'pass (domain of bounce.twitter.com designates 199.16.156.159 as permitted sender)', | |
'x-ymailisg': 'HUq.WUwWLDt6lAQnXg3wAfGN1o6LPrWrzivGCVzzcqdNHaR8 KjFr5XCUy_4_pGxLJIYCJ2MahDvriOUhWUwZk3CvuA1xC6i.eU7gMr20R0pa TVY9cHUiqC.1K3F8hxrbm2nEakr0lmjkkCDkUqYoA0zynO_0jKIJLN0cXrmK LF1vXaa_1637dgYnuOOTN_d4QBh8xZ3iEkmUwJDPYkZp8bHz0aV7BAhfJ5Qe ygkJZPayB5eILh.4gsNxvMOYnESrIvUxa3dgDheBP7TUeZHcbPTdsvqx3SG5 sKuzRId2FzHvoyCcT.RM2EZyQ6gbnZfL_pXnopAHz_tyvkch_Wz5pR.PwaGG bzI28orN40hDz_29F311O5tZjwJGBySwnu_H807Bnmq_KitbhnpC3cEcZydS 2L5cUU9b9eIY.f_UrSjhPVRM_mNCou7qeWrq9n0VMz3wFc35BGaGyheB.Sii JIUXrzui6JYyxXlW1Evx7JIezIp1j7Thmgm7XqIvWnQe8.LjnMt8NCYXWsl3 O.3bb88GF5gBMt4XvkgZIWVhjOlnIFjktHbgyUbNgbig1AevO2tNGIrd4w5L KNH4q8uOzFTBK7dejVGJ4i6XY6Z8OqoX15GCvmH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ html: '...', | |
text: '...', | |
headers: | |
{ 'delivered-to': '[email protected]', | |
received: | |
[ 'by 10.76.90.165 with SMTP id bx5csp523526oab; Fri, 27 Dec 2013 02:41:07 -0800 (PST)', | |
'by 10.194.122.169 with HTTP; Fri, 27 Dec 2013 02:40:46 -0800 (PST)' ], | |
'return-path': '<[email protected]>', | |
'received-spf': 'pass (google.com: domain of [email protected] designates 10.180.20.15 as permitted sender) client-ip=10.180.20.15', | |
'authentication-results': 'mr.google.com; spf=pass (google.com: domain of [email protected] designates 10.180.20.15 as permitted sender) [email protected]; dkim=pass [email protected]', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function randomString(n) { | |
var str = ""; | |
for (var i=0; i<n; i++) { | |
str += String.fromCharCode(Math.floor(Math.random()*26 + 97)) | |
} | |
return str; | |
} | |
randomString(5) // => "xkcdy" | |
randomString(7) // => "idhmtus" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var expect = require('chai').expect; | |
var jsdom = require('jsdom'); | |
var jquery = require('jquery'); // option 2 | |
var TodoView = require('../hello-backbone/views/todo-view'); | |
describe('Backbone.View', function() { | |
var $, todoView; // option 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var chai = require('chai'), | |
expect = chai.expect, | |
sinon = require('sinon'), | |
sinonChai = require('sinon-chai'); | |
var Backbone = require('backbone'); | |
var _ = require('lodash/dist/lodash.underscore'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = new Array(); | |
for (var b = 0; b < 10; b++) { | |
a[0] |= b; // <= ? | |
} |
OlderNewer