-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsolutionyear.js
More file actions
44 lines (30 loc) · 985 Bytes
/
Copy pathsolutionyear.js
File metadata and controls
44 lines (30 loc) · 985 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function solution(year) {
const remainder = year%100
if (remainder>0)
result =+ 1
result = (year-remainder)/100
}
solution(1905)
// // Codewriting
// 300
// Given a year, return the century it is in. The first century spans from the year 1 up to and including the year 100, the second - from the year 101 up to and including the year 200, etc.
// Example
// For year = 1905, the output should be
// solution(year) = 20;
// For year = 1700, the output should be
// solution(year) = 17.
// Input/Output
// [execution time limit] 4 seconds (js)
// [input] integer year
// A positive integer, designating the year.
// Guaranteed constraints:
// 1 ≤ year ≤ 2005.
// [output] integer
// The number of the century the year is in.
// [JavaScript] Syntax Tips
// // Prints help message to the console
// // Returns a string
// function helloWorld(name) {
// console.log("This prints to the console when you Run Tests");
// return "Hello, " + name;
// }