Git Product home page Git Product logo

typescript-exercise-1's Introduction

typescript-exercise-1

Workshop Typescript exercise on data types and functions.

The main purpose of this exercise is to get familiar with Typescsript's data types and function declarations.

Required

For this exercise you need to have NodeJs

NodeJS

and also Typescript installed

$ npm i -g typescript

Exercise 1

Given a language that uses only 4 letters

{ A, T, G, C}

and a grammar of the following 2 rules

A can only pair with T, and vice versa
G can only pair with C, and vice versa

so it is:

A -> T
T -> A
G -> C
C -> G

Goal

Create a function that takes any sequence of those 4 letters and replies with a sequence of the complementary letters i.e the letters they pair with.

Example

So if sequence is

ATGCATCAGACT

Then the solution should be

TACGTAGTCTGA

Guide

Try and be more strict when declaring a variable

const myVar = 'anything';   // Bad!
const myVar: string = 'anything';  // Good!

and also when declaring a function

const add = (x, y) => x + y; // Bad!
const add = (x: number, y: number): number => x + y; // Good!

Extra Help

If you need to convert an enum to string

enum Base { A, T, G, C}
const name: string = Base[Base.A];

If you like, we have provided a file containing a sequence

collagen.ts

You may import it like this

import {collagen} from './collagen';

To compile and run your code

$ tsc your_file.ts && node your_file.js

typescript-exercise-1's People

Contributors

margaris23 avatar

Watchers

James Cloos 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.