Move History

Fork Selected
  • Description

    I Have An Array With Types From Interface iType

    interface iType{ id: number, name: string, };

    const data: iType[] = [ { id: 1 name: "Manny" }, { id: 2 name: "Danny" }, { id: 3 name: "Socciella" }, ];

    Can You Show Only One Data From That Array By ID?

    Code
    export interface iType{
      id: number,
      name: string,
    }
    
    export function findData (data: iType[], selectedData: number): iType {
      // You Can Code Here
      
    }
    Test Cases Failed
    // See https://www.chaijs.com for how to use Chai.
    import { assert } from "chai";
    
    import { findData, iType } from "./solution";
    
    const data: iType[] = [
      {
        id: 1,
        name: "Manny"
      },
      {
        id: 2,
        name: "Danny"
      },
      {
        id: 3,
        name: "Socciella"
      },
    ];
    
    // TODO Add your tests here
    describe("Checking Test Nagatech Basic 3", function() {
      it("Status", function() {
        assert.strictEqual(findData(data, 1), data[0]);
        assert.strictEqual(findData(data, 2), data[1]);
    
      });
    });