俗话说,只因少了一枚马蹄钉,一个王国便就此覆灭。
给定一组输入,生成相应的谚语。
例如,给定列表["nail", "shoe", "horse", "rider", "message", "battle", "kingdom"],你需要输出这首谚语诗谣的完整内容:
For want of a nail the shoe was lost.
For want of a shoe the horse was lost.
For want of a horse the rider was lost.
For want of a rider the message was lost.
For want of a message the battle was lost.
For want of a battle the kingdom was lost.
And all for the want of a nail.
注意,输入的列表可能各不相同;你的解答应能处理任意长度和任意内容的列表。 输出文本的每一行都不应是固定不变的字符串,而应随给定的输入而变化。
如果数组中的最后一个元素是object而不是string,它会包含一个限定词,用来修饰谚语的最后一行。
proverb('nail', 'shoe', { qualifier: 'horseshoe' });
// => For want of a nail the shoe was lost.
// And all for the want of a horseshoe nail.