if&switch写日程安排

124 阅读1分钟
	function pop() {
		return window.prompt(title,'');
	}
	var today = pop();
	var time = '';
	if(today){ 
		title = '上午或下午';
		time = pop()
	}
	var week = ['星期一','星期二','星期三','星期四','星期五'] 
	switch(true) {
		case week.includes(today):
			if(time == '上午' || time == '下午'){
				document.write('苦逼了,要上班')
			} else {
				document.write('没有日程安排');
			}
			break;
		case today == '星期六':
			if(time == '上午'){
				document.write('要睡觉');
			} else if(time == '下午') {
				document.write('要逛街');
			} else {
				document.write('没有日程安排');
			}
			 break;
		case today == '星期日':
			if(time == '上午'){
				document.write('见闺蜜');
			} else if(time == '下午') {
				document.write('吃一顿');
			} else {
				document.write('没有日程安排');
			}
			 break;
		default :
			document.write('没有日程安排');
			break;
	}