Skip to content

Commit c595b90

Browse files
author
Sascha Brink
committed
Fix indention
1 parent 610f3a8 commit c595b90

File tree

7 files changed

+100
-108
lines changed

7 files changed

+100
-108
lines changed

bower.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
2-
"name": "type-coercion",
2+
"name": "javascript-type-coercion",
33
"version": "0.0.1",
4-
"homepage": "https://github.com/robinboehm/angularjs-intensiv-workshop",
4+
"homepage": "https://github.com/angularjs-de/javascript-type-coercion",
55
"authors": [
6-
"Robin Böhm <[email protected]>"
6+
"Robin Böhm <[email protected]>",
7+
"Sascha Brink <[email protected]>"
78
],
89
"license": "MIT",
910
"private": true,
@@ -19,7 +20,6 @@
1920
"angular-route": "~1.2.1",
2021
"google-code-prettify": "~1.0.0",
2122
"angular-bootstrap": "~0.6.0",
22-
"bootstrap": "2.3.2",
2323
"github-fork-ribbon-css": "~0.1.0"
2424
}
2525
}

index.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111
<body>
1212

1313
<div class="container">
14-
<main class="row">
15-
<h1 class="page-header">Tasks: Type Coercion</h1>
16-
<main ng-view class="col-xs-12"></main>
17-
</main>
14+
<h1 class="page-header">JavaScript - Type Coercion Challenge</h1>
15+
<main ng-view></main>
1816
</div>
1917

2018
<div class="github-fork-ribbon-wrapper right">

scripts/config/routeConfig.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
angular.module("typeCoercion")
2-
.config(function ($routeProvider) {
3-
"use strict";
4-
$routeProvider
5-
.when("/", {
6-
templateUrl: "views/main.html"
7-
})
8-
.when("/summary", {
9-
templateUrl: "views/summary.html",
10-
controller: "summaryCtrl"
11-
})
12-
.when("/:taskId", {
13-
templateUrl: "views/task.html",
14-
controller: "taskCtrl"
15-
})
16-
.otherwise({
17-
redirectTo: "/"
18-
});
19-
});
2+
.config(function ($routeProvider) {
3+
"use strict";
4+
$routeProvider
5+
.when("/", {
6+
templateUrl: "views/main.html"
7+
})
8+
.when("/summary", {
9+
templateUrl: "views/summary.html",
10+
controller: "summaryCtrl"
11+
})
12+
.when("/:taskId", {
13+
templateUrl: "views/task.html",
14+
controller: "taskCtrl"
15+
})
16+
.otherwise({
17+
redirectTo: "/"
18+
});
19+
});

scripts/filters/evalFilter.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
angular.module("typeCoercion")
2-
.filter('eval', function () {
3-
return function (input) {
4-
if (/^if/.test(input)) {
5-
input = input.replace('if(', '').replace(')', '');
6-
input = 'new Boolean(' + input + ')';
7-
}
8-
return eval(input).toString();
9-
};
10-
});
2+
.filter('eval', function () {
3+
return function (input) {
4+
if (/^if/.test(input)) {
5+
input = input.replace('if(', '').replace(')', '');
6+
input = 'new Boolean(' + input + ')';
7+
}
8+
return eval(input).toString();
9+
};
10+
});
Lines changed: 57 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,60 @@
11
angular.module("typeCoercion")
2-
.factory("DataHolderService", function () {
3-
'use strict';
4-
function shuffle(o) { //v1.0
5-
for (var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
6-
return o;
7-
};
8-
var tasks = shuffle([
9-
'1 == 1', // returns true
10-
'"1" == 1', // returns true ("1" converts to 1)
11-
'1 == true', // returns true
12-
'0 == false', // returns true
13-
'"" == 0', // returns true ("" converts to 0)
14-
'" " == 0', // returns true (" " converts to 0)
15-
'0 == 1', // returns false
16-
'1 == false', // returns false
17-
'0 == true', // returns false
18-
'0 != false', // returns false
19-
'"" != 0', // returns false ("" converts to 0)
20-
'" " != 0', // returns false (" " converts to 0)
21-
'0 != 1', // returns true
22-
'1 != false', // returns true
23-
'0 != true', // returns true
24-
'1 === 1', // returns true
25-
'"1" === 1', // returns false ("1" is not converted)
26-
'1 === true', // returns false
27-
'0 === false', // returns false
28-
'"" === 0', // returns false ("" is not converted)
29-
'" " === 0', // returns false (" " is not converted)
30-
'0 === 1', // returns false
31-
'1 === false', // returns false
32-
'0 === true', // returns false
33-
'var x, y;\n' +
34-
'x = {};\n' +
35-
'y = x;\n' +
36-
'x != y //?', // returns false (refers to same object in memory)
37-
'var x, y;\nx = {};\ny = x;\nx != {} //?', // returns true (not the same object)
38-
'var x, y;\nx = {};\ny = x;\nx == y //?', // returns true (refers to same object in memory)
39-
'var x, y;\nx = {};\ny = x;\nx == {} //?', // returns false (not the same object)
40-
'var x, y;\nx = {};\ny = x;\nx === y //?', // returns false (not the same object)
41-
'var x, y;\nx = {};\ny = x;\nx === {} //?',
42-
'if("")', // false
43-
'if("5")', // true
44-
'if(0)', // false
45-
'if(-1)', // true
46-
'if(null)', // false
47-
'if(undefined)', // false'// returns false (not the same object)
48-
'null == undefined', // returns true
49-
'null == false', // returns false
50-
'NaN == NaN' // returns false
51-
]),
52-
results = [];
2+
.factory("DataHolderService", function () {
3+
'use strict';
4+
function shuffle(o) { //v1.0
5+
for (var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
6+
return o;
7+
};
8+
var results = [];
9+
var tasks = shuffle([
10+
'1 == 1', // returns true
11+
'"1" == 1', // returns true ("1" converts to 1)
12+
'1 == true', // returns true
13+
'0 == false', // returns true
14+
'"" == 0', // returns true ("" converts to 0)
15+
'" " == 0', // returns true (" " converts to 0)
16+
'0 == 1', // returns false
17+
'1 == false', // returns false
18+
'0 == true', // returns false
19+
'0 != false', // returns false
20+
'"" != 0', // returns false ("" converts to 0)
21+
'" " != 0', // returns false (" " converts to 0)
22+
'0 != 1', // returns true
23+
'1 != false', // returns true
24+
'0 != true', // returns true
25+
'1 === 1', // returns true
26+
'"1" === 1', // returns false ("1" is not converted)
27+
'1 === true', // returns false
28+
'0 === false', // returns false
29+
'"" === 0', // returns false ("" is not converted)
30+
'" " === 0', // returns false (" " is not converted)
31+
'0 === 1', // returns false
32+
'1 === false', // returns false
33+
'0 === true', // returns false
34+
'var x, y;\nx = {};\ny = x;\nx != y //?', // returns false (refers to same object in memory)
35+
'var x, y;\nx = {};\ny = x;\nx != {} //?', // returns true (not the same object)
36+
'var x, y;\nx = {};\ny = x;\nx == y //?', // returns true (refers to same object in memory)
37+
'var x, y;\nx = {};\ny = x;\nx == {} //?', // returns false (not the same object)
38+
'var x, y;\nx = {};\ny = x;\nx === y //?', // returns false (not the same object)
39+
'var x, y;\nx = {};\ny = x;\nx === {} //?',
40+
'if("")', // false
41+
'if("5")', // true
42+
'if(0)', // false
43+
'if(-1)', // true
44+
'if(null)', // false
45+
'if(undefined)', // false'// returns false (not the same object)
46+
'null == undefined', // returns true
47+
'null == false', // returns false
48+
'NaN == NaN' // returns false
49+
]);
5350

54-
return {
55-
getTasks: function () {
56-
return tasks;
57-
},
58-
getResults: function () {
59-
return results;
60-
}
61-
};
51+
return {
52+
getTasks: function () {
53+
return tasks;
54+
},
55+
getResults: function () {
56+
return results;
57+
}
58+
};
6259

63-
});
60+
});

views/main.html

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
<h2>
2-
Description
3-
</h2>
4-
<p>
5-
Just a few simple tasks for JavaScript Type Coercion. <br/>
6-
Just Answer with <em>true</em> or <em>false</em>.
1+
<p class="lead">
2+
A few simple questions for JavaScript Type Coercion. <br/>
3+
Just answer with <strong>true</strong> or <strong>false</strong>.
74
</p>
85

9-
<a href="#/1" class="btn btn-info">Start</a>
6+
<a href="#/1" class="btn btn-info btn-lg">Start challenge</a>

views/task.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212

1313
<hr>
1414

15-
<section>
16-
<button class="btn btn-success" value="true" ng-click="saveResult('true')">True</button>
17-
<button class="btn btn-danger" value="false" ng-click="saveResult('false')">False</button>
18-
</section>
19-
20-
<pre class="prettyprint linenums lang-js" ng-bind="task"></pre>
2115

16+
<pre class="prettyprint linenums lang-js" ng-bind="task"></pre>
17+
<br>
18+
<section class="text-center">
19+
<button class="btn btn-success btn-lg" value="true" ng-click="saveResult('true')">True</button>
20+
<button class="btn btn-danger btn-lg" value="false" ng-click="saveResult('false')">False</button>
21+
</section>

0 commit comments

Comments
 (0)