Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"env": {
"browser": true,
"node": true,
"commonjs": true,
"jest": true,
"es6": true
},
"globals": {
"err": true,
"req": true,
"res": true,
"next": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"no-console": "off",
"indent": [ "error", 2 ],
"quotes": ["error", "single", { "allowTemplateLiterals": true }],
"comma-dangle": ["error", "always-multiline"],
"semi": [ "error", "always" ]
}
}

Binary file added 20200203_213419.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Table of Contents
[1- code challange class 2 array shift ](https://github.com/Goorob-401-advanced-javascript/data-structures-and-algorithms/pull/3)
## Challenge Description

[2- code challange class 3 array binary search ](https://github.com/Goorob-401-advanced-javascript/data-structures-and-algorithms/pull/2)
to write a function to accepts an integer, and returns the nth number in the Fibonacci sequence.

[
## Approach & Efficiency

i use Fibonacci Sequence approch , which is a set of numbers :
0, 1, 1, 2, 3, 5, 8, 13, 21, 34
next number is found by adding up the two numbers before it.

## Solution

![UML](https://github.com/Goorob-401-advanced-javascript/data-structures-and-algorithms/blob/code-challange-4/20200203_213419.jpg)
11 changes: 11 additions & 0 deletions challanges/code-challange-4/code-challange-4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';
function fibFunction(x){
let array = [0, 1];
for (let i = array.length; i < x + 1; i++){
let sum = array[i - 2] + array[i -1];
array.push(sum);
}
return array[x];
}

module.exports = fibFunction ;
7 changes: 7 additions & 0 deletions challanges/code-challange-4/code-challange-4.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';
let validator = require('./code-challange-4.js');
describe('Fibonacci Module',()=>{
it('validate the output arr ' ,()=> {
expect(validator(8)).toEqual( 21 );
});
});
Loading