From dff32a222202ead66e1b4215886b4b39e495d37e Mon Sep 17 00:00:00 2001 From: Gail Matsushima Date: Wed, 28 Oct 2015 19:05:00 -1000 Subject: [PATCH] finished basics.js --- README.md | 1 + basics.js | 57 ++++++++++++ index.html | 5 ++ lib/.DS_Store | Bin 0 -> 6148 bytes lib/js/.DS_Store | Bin 0 -> 6148 bytes lib/js/mocha.js | 14 +-- package.sublime-workspace | 179 ++++++++++++++++++++++++++++++++++++++ test/basics-spec.js | 6 +- 8 files changed, 250 insertions(+), 12 deletions(-) create mode 100644 lib/.DS_Store create mode 100644 lib/js/.DS_Store create mode 100644 package.sublime-workspace diff --git a/README.md b/README.md index e86ac27..206caf6 100644 --- a/README.md +++ b/README.md @@ -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 \ No newline at end of file diff --git a/basics.js b/basics.js index 944afa9..1d6215f 100644 --- a/basics.js +++ b/basics.js @@ -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')); \ No newline at end of file diff --git a/index.html b/index.html index dc46ed3..00d5a18 100644 --- a/index.html +++ b/index.html @@ -9,6 +9,10 @@ +

Person Function

+

DataTypes

+
+
@@ -18,5 +22,6 @@ + diff --git a/lib/.DS_Store b/lib/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..dee0e3ef6901846f5ae79a82155c4009b8f6a42b GIT binary patch literal 6148 zcmeH~u?oUK42Bc!P;lw!c#99<8yrQSpfBJc2qF~}o$t~8lgnatmLh*3`7XJJw*Sy; zL`3_?aVye^NDDX0#=^uD`9jWee-5|tave{|t!B2U@Eo;HCi}5XPys4H1*iZOpaL^e zAkOi2HKS+Zqfh}VFb@Un`;g$q94wXo=|J!i0Blfp!`f#FFj)c2!BU9|Ok;Y`XjLCW ztnTe#itBQ)RMvLU7(O)atTx5Kw6=>TBrwem1}Z=WCJHQT-r4!Thku*@CoN2=02TN% z1+>`>yB;qUXY0r7S^W@ITNgO!mm|FW1R$}acnx>MezFCagQXG`7=Hv@1_mndQw3g) C!VpCO literal 0 HcmV?d00001 diff --git a/lib/js/.DS_Store b/lib/js/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a7dca46df565ea7cdfff92f7b3cadaa8fb9f67f6 GIT binary patch literal 6148 zcmeHK%Sr?>5bV|k2SnJT#~i&V_y=KG1+V%8y6Zugb?2~n&jLsI|% literal 0 HcmV?d00001 diff --git a/lib/js/mocha.js b/lib/js/mocha.js index 079aa58..d677329 100644 --- a/lib/js/mocha.js +++ b/lib/js/mocha.js @@ -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 @@ -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(); diff --git a/package.sublime-workspace b/package.sublime-workspace new file mode 100644 index 0000000..934da50 --- /dev/null +++ b/package.sublime-workspace @@ -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": + { + } +} diff --git a/test/basics-spec.js b/test/basics-spec.js index 170982f..89891f9 100644 --- a/test/basics-spec.js +++ b/test/basics-spec.js @@ -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;