-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
28 lines (24 loc) · 774 Bytes
/
Copy pathapp.js
File metadata and controls
28 lines (24 loc) · 774 Bytes
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
// IIFE declaration
(() => {
"use strict";
// Define our module. The module has no dependencies so the dependency array is empty.
angular
.module("NameCalculator", [])
// Define our controller (viewModel)
.controller("nameCalculatorController", ($scope) => {
$scope.name = "";
$scope.totalValue = 0;
$scope.displayNumeric = function () {
var totalNameValue = calculateNumericForString($scope.name);
$scope.totalValue = totalNameValue;
};
});
// Calculates the ASCII value of a given string
function calculateNumericForString(string) {
var totalStringValue = 0;
for (var i = 0; i < string.length; i++) {
totalStringValue += string.charCodeAt(i);
}
return totalStringValue;
}
})();