Write a function that takes an array of integers as input. For each integer, output the next fibonacci number.
Fibonacci number of Fn is defined by:
Fn = Fn-1 + Fn-2
F1 = 1, F2 = 1
(function(){ var a = b = 3; })(); | |
//此function等同於 | |
(function(){ | |
var a = 3; | |
b = 3; | |
})(); | |
// 所以此IIFE執行完後,在function內宣告的變數a會立即被回收 | |
a; // -> Error: not defined | |
// 但是沒有宣告b,所以b是window內的全域屬性 |
/* | |
請依據以下範本撰寫一個 MyFunc 函式: | |
function MyFunc() { | |
// YOUR CODE HERE | |
} | |
撰寫完成後,必須可以正常執行以下程式碼: | |
var o = MyFunc(); | |
o.get_a() // 回傳 undefined |
/* | |
請完成以下 API 設計,讓你的程式可以執行以下程式碼,並且得到預期的結果。串接 add 的次數沒有上限,最後一個 API 是 result() 才會回傳結果。 | |
$(1).add(2).add(3).add(99).result() === 105 | |
$(1).add(2).add(3).result() === 6 | |
*/ | |
function $(baseNumber) { | |
let total = baseNumber; | |
const obj = {}; | |
obj.add = function(number) { |
/* | |
請完成以下 function a() {} 函式的程式撰寫,讓你的程式可以執行以下程式碼,並且得到預期的結果。 | |
※ 傳入數字的範圍只有 0 ~ 9,且回傳型別必須為 number | |
a(2)[0](3).run() === 203 | |
a(2)[3](3).run() === 233 | |
a(5)[8](2).run() === 582 | |
a(9)[9](9).run() === 999 | |
*/ | |
function a(first) { |
This tutorial was created by Shopify for internal purposes. We've created a public version of it since we think it's useful to anyone creating a GraphQL API.
It's based on lessons learned from creating and evolving production schemas at Shopify over almost 3 years. The tutorial has evolved and will continue to change in the future so nothing is set in stone.
// Start a method chain that will throw an error: | |
// --> foo() [catches error] | |
// -----> bar() [catches / rethrows error] | |
// --------> baz() [throws error] | |
foo(); | |
function foo() { | |
try { | |
bar(); |
describe('...', () => { | |
const RealDate = Date; | |
function mockDate(isoDate) { | |
global.Date = class extends RealDate { | |
constructor(...args) { | |
if (args.length) return new RealDate(...args); | |
return new RealDate(isoDate); | |
} | |
}; |