<<<<<<< HEAD Code Wars - Brett Crafton

Century From Year

Question

Introduction The first century spans from the year 1 up to and including the year 100, the second century - from the year 101 up to and including the year 200, etc. Task Given a year, return the century it is in. Examples

1705 --> 18 1900 --> 19 1601 --> 17 2000 --> 20

Solution by -

My Solution


	function century(year) {
		if(year.length <= 2){
			return "1"
		}
		else {
			let stringYear = String(year)
			let goof = stringYear.split('')
			return goof[goof.length -1] == '0' && goof[goof.length -2] == '0' ? Number(goof.slice(0, -2).join('')) : Number(goof.slice(0, -2).join(''))+1 
		}
		
		}
				

Try it yourself - CodeWars

======= Code Wars - Brett Crafton

Century From Year

Question

Introduction The first century spans from the year 1 up to and including the year 100, the second century - from the year 101 up to and including the year 200, etc. Task Given a year, return the century it is in. Examples

1705 --> 18 1900 --> 19 1601 --> 17 2000 --> 20

Solution by -

My Solution


	function century(year) {
		if(year.length <= 2){
			return "1"
		}
		else {
			let stringYear = String(year)
			let goof = stringYear.split('')
			return goof[goof.length -1] == '0' && goof[goof.length -2] == '0' ? Number(goof.slice(0, -2).join('')) : Number(goof.slice(0, -2).join(''))+1 
		}
		
		}
				

Try it yourself - CodeWars

>>>>>>> 0e614172debaa009c8d31330edbeb3b765b59c39