Giter Club home page Giter Club logo

i-deserve-to-be-hired's Introduction

Interview question for Node.js

本題選用 TypeScript 實作,開發環境 Node.js v14,測試 framework 選用 Jest,CI 使用 GitHub Actions。

Links

  • simple-reverse - 第一版本簡易實作,可處理 happy path,輸入值必須為符合規則之 object,每層均至少包含一組 key-value pair

  • reverse - 第二版本實作,對於大部分不合法的輸入值統一回傳 null;使用者可自行注入 filter,當 object 中包含多組 key-value pair 時,透過 filter 選擇要轉換的路徑。

  • Coverage Report - CI 中透過 Jest 產生

Demo

$ FOLDER=path/to/go # 要用來下載的資料夾路徑
$ git clone [email protected]:o-p/i-deserve-to-be-hired.git $FOLDER && cd $FOLDER
...
# 安裝相依套件,將 TypeScript source code 轉譯成 JavaScript
$ yarn && yarn build
...
# 測試題目 input,確認 output 是否相符
$ node -e "const { reverse } = require('./es'); console.log(JSON.stringify(reverse({ hired: { be: { to: { deserve: 'I' } } } })))"
{"I":{"deserve":{"to":{"be":"hired"}}}}

Question

/**
 * Please use TypeScript/JS to answer question
 * Welcome to answer with unit testing code if you can
 *
 * After you finish coding, please push to your GitHub account and share the link with us.
 */

// Please write a function to reverse the following nested input value into output value

// Input:
let inputValue = {
  hired: {
    be: {
      to: {
      	deserve: 'I'
      }
    }
  }
};

// Output:
let outputValue = {
  I: {
    deserve: {
      to: {
         be: 'hired'
      }
    }
  }
};

i-deserve-to-be-hired's People

Contributors

o-p avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.