In JavaScript, ```if..else``` is the most basic condition statement,
it consists of three parts:```condition, statement1, statement2```, like this:
```python
if condition: statementa
else:         statementb
```
It means that if the condition is true, then execute the statementa, otherwise execute the statementb.If the statementa or statementb more than one line, you need to add ```{``` and ```}``` at the head and tail of statement in JS, to keep the same indentation on Python and to put a `end` in Ruby where it indeed ends.

An example, if we want to judge whether a number is odd or even, we can write code like this:
```python
def odd_even(n):
    if n%2: return "odd number"
    else:   return "even number"
```

If there is more than one condition to judge, we can use the compound if...else statement. an example:
```python
def old_young(age):
    if age<16:        return "children"
    elif (age<50): return "young man" #use "else if" if needed
    else:             return "old man"
```
This function returns a different value depending on the parameter age.

Looks very complicated? Well, JS and Ruby also support the ```ternary operator``` and Python has something similar too:
```python
statementa if condition else statementb
```
Condition and statement separated by "?", different statement separated by ":" in both Ruby and JS; in Python you put the condition in the middle of two alternatives.
The two examples above can be simplified with ternary operator:
```python
def odd_even(n):
    return "odd number" if n%2 else "even number"
def old_young(age):
    return "children" if age<16 else "young man" if age<50 else "old man"
```

## Task:
Complete function `saleHotdogs`/`SaleHotDogs`/`sale_hotdogs`, function accept 1  parameters:`n`, n is the number of customers to buy hotdogs, different numbers have different prices (refer to the following table), return a number that the customer need to pay how much money.
```
+---------------+-------------+
|  numbers n    | price(cents)|
+---------------+-------------+
|n<5            |    100      |
+---------------+-------------+
|n>=5 and n<10  |     95      |
+---------------+-------------+
|n>=10          |     90      |
+---------------+-------------+
```
You can use if..else or ternary operator to complete it.
    
    When you have finished the work, click "Run Tests" to see if your code is working properly.
    
    In the end, click "Submit" to submit your code pass this kata.
    
## [Series](http://github.com/myjinxin2015/Katas-list-of-Training-JS-series):

( ↑↑↑ Click the link above can get my newest kata list, Please add it to your favorites)

 - [#1: create your first JS function helloWorld](http://www.codewars.com/kata/571ec274b1c8d4a61c0000c8)
 - [#2: Basic data types--Number](http://www.codewars.com/kata/571edd157e8954bab500032d)
 - [#3:  Basic data types--String](http://www.codewars.com/kata/571edea4b625edcb51000d8e)
 - [#4:  Basic data types--Array](http://www.codewars.com/kata/571effabb625ed9b0600107a)
 - [#5:  Basic data types--Object](http://www.codewars.com/kata/571f1eb77e8954a812000837)
 - [#6:  Basic data types--Boolean and conditional statements if..else](http://www.codewars.com/kata/571f832f07363d295d001ba8)
 - [#7:  if..else and ternary operator](http://www.codewars.com/kata/57202aefe8d6c514300001fd)
 - [#8: Conditional statement--switch](http://www.codewars.com/kata/572059afc2f4612825000d8a)
 - [#9: loop statement --while and do..while](http://www.codewars.com/kata/57216d4bcdd71175d6000560)
 - [#10: loop statement --for](http://www.codewars.com/kata/5721a78c283129e416000999)
 - [#11: loop statement --break,continue](http://www.codewars.com/kata/5721c189cdd71194c1000b9b)
 - [#12: loop statement --for..in and for..of](http://www.codewars.com/kata/5722b3f0bd5583cf44001000)
 - [#13: Number object and  its properties](http://www.codewars.com/kata/5722fd3ab7162a3a4500031f)
 - [#14: Methods of Number object--toString() and toLocaleString()](http://www.codewars.com/kata/57238ceaef9008adc7000603)
 - [#15: Methods of Number object--toFixed(), toExponential() and toPrecision()](http://www.codewars.com/kata/57256064856584bc47000611)
 - [#16: Methods of String object--slice(), substring() and substr()](http://www.codewars.com/kata/57274562c8dcebe77e001012)
 - [#17: Methods of String object--indexOf(), lastIndexOf() and search()](http://www.codewars.com/kata/57277a31e5e51450a4000010)
 - [#18: Methods of String object--concat() split() and its good friend join()](http://www.codewars.com/kata/57280481e8118511f7000ffa)
 - [#19: Methods of String object--toUpperCase() toLowerCase() and replace()](http://www.codewars.com/kata/5728203b7fc662a4c4000ef3)
 - [#20: Methods of String object--charAt() charCodeAt() and fromCharCode()](http://www.codewars.com/kata/57284d23e81185ae6200162a)
 - [#21: Methods of String object--trim() and the string template](http://www.codewars.com/kata/5729b103dd8bac11a900119e)
 - [#22: Unlock new skills--Arrow function,spread operator and deconstruction](http://www.codewars.com/kata/572ab0cfa3af384df7000ff8)
 - [#23: methods of arrayObject---push(), pop(), shift() and unshift()](http://www.codewars.com/kata/572af273a3af3836660014a1)
 - [#24: methods of arrayObject---splice() and slice()](http://www.codewars.com/kata/572cb264362806af46000793)
 - [#25: methods of arrayObject---reverse() and sort()](http://www.codewars.com/kata/572df796914b5ba27c000c90)
 - [#26: methods of arrayObject---map()](http://www.codewars.com/kata/572fdeb4380bb703fc00002c)
 - [#27: methods of arrayObject---filter()](http://www.codewars.com/kata/573023c81add650b84000429)
 - [#28: methods of arrayObject---every() and some()](http://www.codewars.com/kata/57308546bd9f0987c2000d07)
 - [#29: methods of arrayObject---concat() and join()](http://www.codewars.com/kata/5731861d05d14d6f50000626)
 - [#30: methods of arrayObject---reduce() and reduceRight()](http://www.codewars.com/kata/573156709a231dcec9000ee8)
 - [#31: methods of arrayObject---isArray() indexOf() and toString()](http://www.codewars.com/kata/5732b0351eb838d03300101d)
 - [#32: methods of Math---round() ceil() and floor()](http://www.codewars.com/kata/5732d3c9791aafb0e4001236)
 - [#33: methods of Math---max() min() and abs()](http://www.codewars.com/kata/5733d6c2d780e20173000baa)
 - [#34: methods of Math---pow() sqrt() and cbrt()](http://www.codewars.com/kata/5733f948d780e27df6000e33)
 - [#35: methods of Math---log() and its family](http://www.codewars.com/kata/57353de879ccaeb9f8000564)
 - [#36: methods of Math---kata author's lover:random()](http://www.codewars.com/kata/5735956413c2054a680009ec)
 - [#37: Unlock new weapon---RegExp Object](http://www.codewars.com/kata/5735e39313c205fe39001173)
 - [#38: Regular Expression--"^","$", "." and test()](http://www.codewars.com/kata/573975d3ac3eec695b0013e0)
 - [#39: Regular Expression--"?", "*", "+" and "{}"](http://www.codewars.com/kata/573bca07dffc1aa693000139)
 - [#40: Regular Expression--"|", "[]" and "()"](http://www.codewars.com/kata/573d11c48b97c0ad970002d4)
 - [#41: Regular Expression--"\"](http://www.codewars.com/kata/573e6831e3201f6a9b000971)
 - [#42: Regular Expression--(?:), (?=) and (?!)](http://www.codewars.com/kata/573fb9223f9793e485000453)

Difficulty: EASY
Tags: Fundamentals

Starter code:
def sale_hotdogs(n):
	

Solutions:
def sale_hotdogs(n):
	return n * (100 if n < 5 else 95 if n < 10 else 90)


def sale_hotdogs(n):
	return n * [90, 95, 100][(n < 10) + (n < 5)]


class Color(object):
	BLACK = 0
	RED = 1

class Node(object):
	__slots__ = ('r', 'left', 'right', 'value', 'color', 'parent')

	def __init__(self, r, value, parent=None, color=Color.RED):
		self.r = r
		self.value = value
		self.parent = parent
		self.color = color
		self.left = None
		self.right = None

	def value_copy(self, other):
		self.r = other.r
		self.value = other.value

class RangeDict(dict):

	def __init__(self, mapping=None, iterable=None):
		self._root = None
		if mapping or iterable:
			for (k, v) in mapping.items() if mapping else iterable:
				self[k] = v

	def __setitem__(self, r, v):
		if r[1] < r[0]:
			raise KeyError
		node = self._insert(r, v)
		self._insert_adjust(node)

	def _insert(self, r, v):
		if not self._root:
			self._root = Node(r, v)
			return self._root
		cur = self._root
		while True:
			if r[1] < cur.r[0]:
				if not cur.left:
					cur.left = Node(r, v, cur)
					return cur.left
				cur = cur.left
			elif r[0] > cur.r[1]:
				if not cur.right:
					cur.right = Node(r, v, cur)
					return cur.right
				cur = cur.right
			else:
				raise KeyError

	def _insert_adjust(self, node):
		if not node.parent:
			node.color = Color.BLACK
			return
		if node.parent.color == Color.BLACK:
			return
		uncle = self.sibling(node.parent)
		if node_color(uncle) == Color.RED:
			node.parent.color = Color.BLACK
			uncle.color = Color.BLACK
			node.parent.parent.color = Color.RED
			return self._insert_adjust(node.parent.parent)
		parent = node.parent
		grandparent = parent.parent
		if self.is_left_son(parent, grandparent):
			if self.is_left_son(node, parent):
				self.right_rotate(grandparent)
				grandparent.color = Color.RED
				parent.color = Color.BLACK
			else:
				self.left_rotate(parent)
				self.right_rotate(grandparent)
				grandparent.color = Color.RED
				node.color = Color.BLACK
		elif self.is_left_son(node, parent):
			self.right_rotate(parent)
			self.left_rotate(grandparent)
			grandparent.color = Color.RED
			node.color = Color.BLACK
		else:
			self.left_rotate(grandparent)
			grandparent.color = Color.RED
			parent.color = Color.BLACK

	def _find_key(self, key):
		cur = self._root
		while cur:
			if key > cur.r[1]:
				cur = cur.right
			elif key < cur.r[0]:
				cur = cur.left
			else:
				break
		return cur

	def _find_range(self, r):
		cur = self._root
		while cur:
			if r[1] < cur.r[0]:
				cur = cur.left
			elif r[0] > cur.r[1]:
				cur = cur.right
			elif r[0] == cur.r[0] and r[1] == cur.r[1]:
				return cur
			else:
				raise KeyError
		raise KeyError

	def __getitem__(self, key):
		tar = self._find_key(key)
		if tar:
			return tar.value
		raise KeyError

	def __contains__(self, key):
		return bool(self._find_key(key))

	def __delitem__(self, r):
		node = self._find_range(r)
		if node.left and node.right:
			left_rightest_child = self.find_rightest(node.left)
			node.value_copy(left_rightest_child)
			node = left_rightest_child
		self._delete(node)

	def _delete(self, node):
		child = node.left if node.left else node.right
		if not node.parent:
			self._root = child
			if self._root:
				self._root.parent = None
				self._root.color = Color.BLACK
			return
		parent = node.parent
		if not child:
			child = Node(None, None, parent, Color.BLACK)
		if self.is_left_son(node, parent):
			parent.left = child
		else:
			parent.right = child
		child.parent = parent
		if node.color == Color.RED:
			return
		if node_color(child) == Color.RED:
			child.color = Color.BLACK
			return
		self._delete_adjust(child)
		if not child.r:
			parent = child.parent
			if self.is_left_son(child, parent):
				parent.left = None
			else:
				parent.right = None

	def _delete_adjust(self, node):
		if not node.parent:
			node.color = Color.BLACK
			return
		parent = node.parent
		sibling = self.sibling(node)
		if node_color(sibling) == Color.RED:
			if self.is_left_son(node, parent):
				self.left_rotate(parent)
			else:
				self.right_rotate(parent)
			parent.color = Color.RED
			sibling.color = Color.BLACK
			sibling = self.sibling(node)
		if not self.is_black(parent) and self.is_black(sibling.left) and self.is_black(sibling.right):
			parent.color = Color.BLACK
			sibling.color = Color.RED
			return
		if self.is_black(parent) and self.is_black(sibling.left) and self.is_black(sibling.right):
			sibling.color = Color.RED
			return self._delete_adjust(parent)
		if self.is_left_son(node, parent):
			if not self.is_black(sibling.left) and self.is_black(sibling.right):
				sibling.left.color = Color.BLACK
				sibling.color = Color.RED
				self.right_rotate(sibling)
				sibling = sibling.parent
			sibling.color = parent.color
			parent.color = Color.BLACK
			sibling.right.color = Color.BLACK
			self.left_rotate(parent)
		else:
			if not self.is_black(sibling.right) and self.is_black(sibling.left):
				sibling.right.color = Color.BLACK
				sibling.color = Color.RED
				self.left_rotate(parent)
				sibling = sibling.parent
			sibling.color = parent.color
			parent.color = Color.BLACK
			sibling.left.color = Color.RED
			self.right_rotate(parent)

	def left_rotate(self, node):
		right_son = node.right
		if not node.parent:
			self._root = right_son
		elif self.is_left_son(node, node.parent):
			node.parent.left = right_son
		else:
			node.parent.right = right_son
		right_son.parent = node.parent
		node.parent = right_son
		node.right = right_son.left
		right_son.left = node

	def right_rotate(self, node):
		left_son = node.left
		if not node.parent:
			self._root = left_son
		elif self.is_left_son(node, node.parent):
			node.parent.left = left_son
		else:
			node.parent.right = left_son
		left_son.parent = node.parent
		node.parent = left_son
		node.left = left_son.right
		left_son.right = node

	@staticmethod
	def sibling(node):
		if node.parent.left == node:
			return node.parent.right
		else:
			return node.parent.left

	@staticmethod
	def is_left_son(child, parent):
		if parent.left == child:
			return True
		else:
			return False

	@staticmethod
	def find_rightest(node):
		while node.right:
			node = node.right
		return node

	@staticmethod
	def is_black(node):
		return node_color(node) == Color.BLACK

def node_color(node):
	if not node:
		return Color.BLACK
	return node.color

def in_order(root):
	ret = []
	if not root:
		return []
	return in_order(root.left) + [root.value] + in_order(root.right)

def height(root):
	if not root:
		return 0
	return 1 + max(height(root.left), height(root.right))

def sale_hotdogs(n):
	d = RangeDict({(0, 5 - 1): 100, (5, 10 - 1): 95, (10, float('inf')): 90})
	return d[n] * n


def sale_hotdogs(n):
	return n * (n < 5 and 100 or (n < 10 and 95) or 90)


sale_hotdogs = lambda n: (100 - 5 * ((n >= 5) + (n >= 10))) * n


def sale_hotdogs(n):
	if n < 5 and n > 0:
		return n * 100
	elif n >= 5 and n < 10:
		return n * 95
	elif n >= 10:
		return n * 90
	else:
		return 0


def sale_hotdogs(n):
	return n * (20 - ((n > 9) + (n > 4))) * 5


sale_hotdogs = lambda n: n * [90, [95, 100][n < 5]][n < 10]


def sale_hotdogs(n):
	return n * (100 - ((n > 4) * 5 + (n > 9) * 5))


def sale_hotdogs(n):
	return [n * (100 - int(n * 0.2) * 5), n * 90][n > 10]


def sale_hotdogs(n):
	return n * 100 if 0 <= n < 5 else n * 95 if 4 < n < 10 else n * 90


def sale_hotdogs(n):
	discount = 0
	if n >= 5 and n < 10:
		discount = 5
	elif n >= 10:
		discount = 10
	return (100 - discount) * n


def sale_hotdogs(n):
	total = 0
	for i in range(n):
		if n < 5:
			total += 100
		elif 5 <= n < 10:
			total += 95
		else:
			total += 90
	return total


def sale_hotdogs(n):
	return n * 100 if 0 < n < 5 else n * 95 if n in range(5, 10) else n * 90


def sale_hotdogs(n):
	return 100 * n if n < 5 else 90 * n if n > 9 else 95 * n


sale_hotdogs = lambda n: n * (100 if n < 5 else 90 if n >= 10 else 95)


def sale_hotdogs(n):
	return n * (100 - (0 if n < 5 else 5 if n < 10 else 10))


def sale_hotdogs(n):
	if n < 5:
		return n * 100
	elif 5 <= n < 10:
		return n * 95
	return n * 90


def sale_hotdogs(n):
	return [n * 95, n * 100, n * 90][(n < 5) - (n > 9)]


def sale_hotdogs(n):
	if n < 5:
		bill = 100
	elif n < 10:
		bill = 95
	else:
		bill = 90
	return n * bill


def sale_hotdogs(n):
	return {0: 100, 1: 95}.get(n // 5, 90) * n


def sale_hotdogs(n):
	if n >= 5 and n < 10:
		return n * 95
	if n < 5:
		return n * 100
	if n >= 10:
		return n * 90


sale_hotdogs = lambda n: ((n < 10 and n >= 5) and 95 or (n >= 10 and 90) or 100) * n


def sale_hotdogs(n):
	return (100, 95, 90)[sum((n > 4, n > 9))] * n


def sale_hotdogs(n):
	if n < 5:
		return n * 100
	elif 5 <= n < 10:
		return n * 100 - n * 5
	else:
		return n * 100 - n * 10


def sale_hotdogs(n: int) -> int:
	factor = 90
	if n < 5:
		factor = 100
	elif n < 10:
		factor = 95
	return n * factor


def sale_hotdogs(n):
	return n * 100 * (0 <= n < 5) + n * 95 * (n >= 5 and n < 10) + n * 90 * (n >= 10)


def sale_hotdogs(customers):
	price = 100 if customers < 5 else 95 if 5 <= customers < 10 else 90
	return customers * price


def sale_hotdogs(n):
	price = {n < 5: n * 100, 5 <= n < 10: n * 95, n >= 10: n * 90}
	return price.get(True)


def sale_hotdogs(n):
	return n * (100 - 5 * ((n >= 5) + (n >= 10)))


def sale_hotdogs(n):
	(a, b) = (range(0, 5), range(5, 10))
	if n in a:
		return n * 100
	elif n in b:
		return n * 95
	else:
		return n * 90


def sale_hotdogs(n):
	price = 100 if n < 5 else 95 if 5 <= n and n < 10 else 90
	return n * price