Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ Test your basic javascript foundation.
1. All your work will be done in the file named: `basics.js`
1. Run tests by running the command: `npm test`
1. Make all the test pass!
w
57 changes: 57 additions & 0 deletions basics.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,81 @@
/* Create a `myName` variable and assign it a String value */

function Person (name) {

var myName = name;
document.createElement(myName);
return myName;
}
console.log(Person('Gail'));


/* Create a `person` variable and give it 2 properties,
* `name`, assign it the same name as before,
* as well as an `age` (number);
*/
var Person = ['Gail', 40];


/* Create a function called `greet`,
* it should take a 1 parameter, `name`
* and it should print "Hello, my name is {name}"
*/
function greet (name) {
return "Hello, my name is " + name;

}
console.log(greet());
/* Create a variable called `canDrive`,
* if it should be true if your person object is at least 16 years old
*/
function canDrive (age) {

if (age >= 16) {return true;}
else if (age < 16) {return false;}
}
console.log(greet('Hector'));
console.log(canDrive(29));
/* Create an array called `dataTypes` with atleast 1 of every data type;
* (there are 6 different data types);
*/
function findDataType (dataTypes) {

var types = ['string', 'booleans', null, 'undefined', 'numbers', 'symbols'];
for ( var i = 0; i < dataTypes.length; i++ ) {
dataTypes = types[i];

if ( dataTypes[i] === null ) {
types.push( null );
}
else {
types.push( typeof dataTypes[i] );
}
}
}

findDataType ();
types.should.include( 'string' );
types.should.include( 'number' );
types.should.include( 'undefined' );
types.should.include( 'object' );
types.should.include( 'boolean' );
types.should.include( null );



/* Create a Dog object
* it should have a `bark` function that makes your dog bark!
* It should also have a name attribute with the value of 'Spot'
*/
function bark (sound, name){

var dog = {

name: 'Spot',
age: 15,
color: 'yellow',
};

return name + " " + "really likes to" + " " + sound + "!";
}
console.log(bark('bark', 'Spot'));
5 changes: 5 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
<link rel="stylesheet" href="lib/css/mocha.css">
</head>
<body>
<h2>Person Function</h2>
<h3>DataTypes</h3>
<div id="MainDiv"> </div>
<div id='Person'> </div>
<div id="mocha"></div>
<script src="/lib/js/mocha.js" type="text/javascript"></script>
<script src="/lib/js/chai.js" type="text/javascript"></script>
Expand All @@ -18,5 +22,6 @@
<script>mocha.setup('bdd');</script>
<script src="/test/basics-spec.js"type="text/javascript"></script>
<script>mocha.run();</script>
</script>
</body>
</html>
Binary file added lib/.DS_Store
Binary file not shown.
Binary file added lib/js/.DS_Store
Binary file not shown.
14 changes: 7 additions & 7 deletions lib/js/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -700,28 +700,28 @@ Progress.prototype.draw = function(ctx){
, y = half
, rad = half - 1
, fontSize = this._fontSize;

ctx.font = fontSize + 'px ' + this._font;

var angle = Math.PI * 2 * (percent / 100);
ctx.clearRect(0, 0, size, size);

// outer circle
ctx.strokeStyle = '#9f9f9f';
ctx.beginPath();
ctx.arc(x, y, rad, 0, angle, false);
ctx.stroke();

// inner circle
ctx.strokeStyle = '#eee';
ctx.beginPath();
ctx.arc(x, y, rad - 1, 0, angle, true);
ctx.stroke();

// text
var text = this._text || (percent | 0) + '%'
, w = ctx.measureText(text).width;

ctx.fillText(
text
, x - w / 2 + 1
Expand Down Expand Up @@ -4947,7 +4947,7 @@ Runner.prototype.uncaught = function(err){
debug('uncaught undefined exception');
err = new Error('Catched undefined error, did you throw without specifying what?');
}

var runnable = this.currentRunnable;
if (!runnable || 'failed' == runnable.state) return;
runnable.clearTimeout();
Expand Down
179 changes: 179 additions & 0 deletions package.sublime-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
{
"auto_complete":
{
"selected_items":
[
]
},
"buffers":
[
],
"build_system": "",
"build_system_choices":
[
],
"build_varint": "",
"command_palette":
{
"height": 147.0,
"last_filter": "install",
"selected_items":
[
[
"install",
"Package Control: Install Package"
]
],
"width": 467.0
},
"console":
{
"height": 126.0,
"history":
[
"import urllib.request,os,hashlib; h = '2915d1851351e5ee549c20394736b442' + '8bc59f460fa1548d1514676163dafc88'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)"
]
},
"distraction_free":
{
"menu_visible": true,
"show_minimap": false,
"show_open_files": false,
"show_tabs": false,
"side_bar_visible": false,
"status_bar_visible": false
},
"file_history":
[
"/Users/Chsluv/devleague/gee-mail/css/style.css",
"/Users/Chsluv/devleague/js-basics/lib/css/mocha.css",
"/Users/Chsluv/devleague/js-basics/test/basics-spec.js",
"/Users/Chsluv/devleague/js-basics/lib/js/sinon.js",
"/Users/Chsluv/devleague/js-basics/lib/js/sinon-chai.js",
"/Users/Chsluv/devleague/js-basics/lib/js/mocha.js",
"/Users/Chsluv/devleague/js-basics/lib/js/chai.js",
"/Users/Chsluv/devleague/js-basics/package.json",
"/Users/Chsluv/Library/Application Support/Sublime Text 3/Packages/User/Preferences.sublime-settings"
],
"find":
{
"height": 30.0
},
"find_in_files":
{
"height": 0.0,
"where_history":
[
]
},
"find_state":
{
"case_sensitive": false,
"find_history":
[
"bdd"
],
"highlight": true,
"in_selection": false,
"preserve_case": false,
"regex": false,
"replace_history":
[
],
"reverse": false,
"show_context": true,
"use_buffer2": true,
"whole_word": false,
"wrap": true
},
"groups":
[
{
"sheets":
[
]
}
],
"incremental_find":
{
"height": 30.0
},
"input":
{
"height": 0.0
},
"layout":
{
"cells":
[
[
0,
0,
1,
1
]
],
"cols":
[
0.0,
1.0
],
"rows":
[
0.0,
1.0
]
},
"menu_visible": true,
"output.find_results":
{
"height": 0.0
},
"pinned_build_system": "",
"project": "package.sublime-project",
"replace":
{
"height": 56.0
},
"save_all_on_build": true,
"select_file":
{
"height": 0.0,
"last_filter": "",
"selected_items":
[
],
"width": 0.0
},
"select_project":
{
"height": 0.0,
"last_filter": "",
"selected_items":
[
],
"width": 0.0
},
"select_symbol":
{
"height": 0.0,
"last_filter": "",
"selected_items":
[
],
"width": 0.0
},
"selected_group": 0,
"settings":
{
},
"show_minimap": true,
"show_open_files": false,
"show_tabs": true,
"side_bar_visible": true,
"side_bar_width": 150.0,
"status_bar_visible": true,
"template_settings":
{
}
}
6 changes: 1 addition & 5 deletions test/basics-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ describe( 'Main', function() {
sandbox.restore();
});

describe( 'person', function() {
it( 'should have a variable called `myName`', function() {
expect( myName ).to.exist;
( typeof myName ).should.equal( 'string' );
});


it( 'should have a person object with the same name', function() {
expect( person ).to.exist;
Expand Down