我是AngularJS的新手.我只想将JSON文件数据加载到位于工厂中的变量中.
myApp.factory('quizFactory', function () {
var questions = [
{
"setId":1,
"question":"What is the value of the 7 in the following number? 850,765",
"options": ["70", "7", "7000", "700"],
"answer": 3
},
{
"setId":2,
"question":"Is 7 & 9 even or odd?",
"options": ["Even", "Odd", "Can't Say", "Dont know"],
"answer": 1
},
{
"setId":3,
"question":"In the number 5,281,946 what is the value of the 3rd place?",
"options": ["100", "10,000", "1,000,000", "1,000"],
"answer": 0
},
{
"setId":4,
"question":"Is 12 + 50 even or …Run Code Online (Sandbox Code Playgroud) 我的任务:
给定一个数字,比如说 prod(对于产品),我们搜索两个斐波那契数 F(n) 和 F(n+1) 验证
Run Code Online (Sandbox Code Playgroud)F(n) * F(n+1) = prod if F(n) * F(n+1) = prod您的函数 productFib 接受一个整数 (prod) 并返回一个数组:
Run Code Online (Sandbox Code Playgroud)[F(n), F(n+1), True] elseF(m) 是最小的,例如 F(m) * F(m+1) > prod
Run Code Online (Sandbox Code Playgroud)[F(m), F(m+1), False]例子:
Run Code Online (Sandbox Code Playgroud)productFib(714) # should return [21, 34, True], # since F(8) = 21, F(9) = 34 and 714 = 21 * 34 productFib(800) # should return [34, 55, False], # since F(8) = 21, F(9) = 34, F(10) = 55 and 21 * …