Coder Social home page Coder Social logo

lab-typescript-arrays-and-functions's Introduction

Image description

ProGrad Lab | Typescript - Arrays

Introduction

In this lab, we are going to work with arrays in TypeScript. We are going to perform different operations following different strategies using Typescript. In this process, we will cover several important topics such as variable types, arrays, functions, classes, and interfaces.

Project Structure The project structure will be as follows:

starter-code/
├── progression-1
    ├── index.html
    ├── main.js
    └── appservice.ts

You are going to work over the *.ts files.

Note: Remember that the *.js files are generated every time we save the TypeScript files in our solution.

Learning Goals

After this lesson, you will be able to:

  • Develop basic TypeScript functions.
  • Develop arrays and perform some array related operations.
  • Work with mixed arrays.
  • Create a TypeScript interface, and use it from a class.
  • Implement two different interfaces and use them from classes.

Requirements

  • Fork this repo.
  • Clone this repo.
  • Install Typescript on your computer using the below command.

$ npm install -g typescript

Submission

Upon completion, run the following commands:

$ git add .
$ git commit -m "done"
$ git push origin master

Navigate to your repo and create a pull request from your master branch to the original repository master branch. In the pull request name, add your ProGrad Id and last names separated by a dash "-"

How to run the project

To compile ths project

  • Open the terminal inside VScode editor and execute the following command.
    • tsc main.ts
  • Once you complie your typescript code, main.js file gets generated automatically.
  • Now, run the main.js file to see the output. To run the file, use the command given below
    • node main.js
  • You can see the output in the terminal.
  • Also open the index.html and see the output in browser console.

Complile&Run

Progression #1:

  • Go to app-service.ts.
  • Create an interface called StringManipulationService and don't forget to export it.
  • Define the following methods inside the StringManipulationService,
    • arrayFindMultiples(myArray : any) : Array;
    • arraySeparate(myArray : any) : Array;
    • arraySplit(myString : string) : Array;
    • arraySort(myArray : any) : Array;
    • arrayReplace(myArray : any) : Array;

Progression #2:

  • Go to main.ts.
  • Create a class called as ArrayManipulations which should implement the StringManipulationService.
  • Your class should implement all the 5 methods.
    • arrayFindMultiples(myArray : any) : Array method is used to find the multiples of 5 and 10 in the given array.
    • arraySeparate(myArray : any) : Array method is used to find the string values in the mixed array and return them.
    • arraySplit(myString : string) : Array method is used to find the prime number in the mixed array. First identify the numbers in the array, typecast it and then check whether the number is a prime number or not.
    • arraySort(myArray : any) : Array method is used to sort the given array of strings.
    • arrayReplace(myArray : any) : Array method is to used to find the numbers which are divisible by 3 and replace it with 5.

Happy Coding ProGrad ❤️

lab-typescript-arrays-and-functions's People

Contributors

coder-venkateshs avatar nethravathi-m avatar prograd-org 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.