題目:less
Generators can be used to wonderful things. You can use them for numerous things, but here is one specific example. You are studying for a test so you must practice your multiplication, but you don't have a multiplication table showing the different examples. You have decided to create a generator that prints out a limitless list of time tables.ide
發電機能夠用來作奇妙的事情。你能夠用它們來作不少事情,但這裏有一個具體的例子。你在爲一個測試而學習,因此你必須練習乘法,可是你沒有一個乘法表來顯示不一樣的例子。您已經決定建立一個生成器,它打印出一個無限的時間表列表。學習
Your generator must take one parameter a
then everytime the generator is called you must return a string in the format of: 'a x b = c'
where c is the answer. Also, the value of b
, which starts at 1, must increment by 1 each time!測試
您的生成器必須接受一個參數,而後每次調用生成器時,必須以「a x b=c」的格式返回一個字符串,其中c就是答案。一樣,從1開始的b的值必須每次遞增1!spa
Sample Tests:code
Test.describe("Fixed Tests", _ => { var gen = generator(1); Test.assertEquals(gen.next().value, '1 x 1 = 1', '1 x 1 = 1') Test.assertEquals(gen.next().value, '1 x 2 = 2', '1 x 2 = 2') Test.assertEquals(gen.next().value, '1 x 3 = 3', '1 x 3 = 3') Test.assertEquals(gen.next().value, '1 x 4 = 4', '1 x 4 = 4') Test.assertEquals(gen.next().value, '1 x 5 = 5', '1 x 5 = 5') });
答案:orm