如何比较2字符串消息

时间:2017-09-19 09:44:04

标签: javascript

  • 我有简单的两个消息(字符串),我想比较2个单词" coffee" ,"茶" ,如果在第一条消息中 喝咖啡"咖啡"第二条消息必须要有"茶"在那。 **如果是这个和所有其他词相同,那就是真的。 **可以显示这两个词在这一点上是否有差异 **如果消息中的其他单词有误,则

  • 如何检查单词的总和是否相等

  • 如何逐个循环检查

var message 1 ="他非常喜欢喝咖啡,他总是在早上和下午喝咖啡,有些人喝咖啡多喝一杯。如果他必须长时间工作,他必须再喝一杯咖啡。在一个月里,他喝了很多杯咖啡。&#34 ;;

var message 2 ="他非常喜欢喝茶,他总是在早上和下午喝茶,有些人他们多喝一杯果汁。如果他必须长时间工作,他必须再喝一杯茶。在一个月里,他喝了很多杯茶。&#34 ;;

function compare(message_1,message_2)
{   
}
如果显示这样的结果,它会很好。

.. 他非常喜欢喝一杯咖啡,他总是在早上和下午喝一杯咖啡,因为有些人他们喝了 !!! juice !!! 更多一杯。如果他必须长时间工作,他必须再次喝一杯咖啡。在 !!! year !!! 他喝了很多杯咖啡。

谢谢

1 个答案:

答案 0 :(得分:0)



var message = prompt("");
if(message == "coffee"){
alert("He like to drink a coffee very much, he always drink a coffee in the moring and in the afternoon for some they he drink coffee more one cup. If he have to work over time he have to drink a coffee again. In a month he drank coffee a lot cup.")
}else if(message == "tea"){
alert( "He like to drink a tea very much, he always drink a tea in the moring and in the afternoon for some they he drink juice more one cup. If he have to work over time he have to drink a tea again. In a month he drank tea a lot cup.")
}else{
alert('choose tea or coffee')
}