-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
42 lines (42 loc) · 1.18 KB
/
Copy pathApp.js
File metadata and controls
42 lines (42 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
(function(){
'use strict';
angular.module('LunchCheck',[])
.controller('LunchCheckController', ['$scope', LunchCheckController]);
function LunchCheckController($scope) {
$scope.list = "";
$scope.result = "";
$scope.Modifcolor = "";
$scope.Modif = function (){
if ($scope.result == "Enjoy!" || $scope.result == "Too much!") {
$scope.Modifcolor = "green";
} else if($scope.result ="Please enter data first"){
$scope.Modifcolor = "red";
}
};
$scope.CheckList = function() {
var CountComma = 0;
const chars = $scope.list.split('');
if (chars != "") {
var lastCheck = false;
for(var i = 0; i < chars.length ; i++) {
if(chars[i] == "," || chars[i] == " " ) {
if(lastCheck == false) {
CountComma += 1;
lastCheck = true;
}
} else {
lastCheck = false;
}
}
if(CountComma <= 3) {
$scope.result = "Enjoy!";
} else if (CountComma > 3) {
$scope.result = "Too much!";
}
} else {
$scope.result ="Please enter data first";
}
$scope.Modif()
};
};
})();