GithubHelp home page GithubHelp logo

angular9_march's People

Contributors

sharma-nareshit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

angular9_march's Issues

Task 1

/*Task :

  • Create a method that can accept parameters
    Method() { printing value }
    Method(a, b) { addition of values }
    */

class cal1 {
Value1:number=10;
value2:number=20;
sum1():void {
console.log(Sum is ${this.Value1+this.value2});
}
multical(a:number,b:number):void {
console.log(SUM=${a+b});
}
}
let obj=new cal1();
obj.sum1();
console.log('------------------');
obj.multical(567,552);

TASK on Polymorphism

/*Task :

  • Create a Method that single can perform all mathematical operations like
    add, sub, mul, div
    Method(a,b,..) add, sub, mul
    you can pass parameter and operation type so that it will perform that operation on those parameters.
    Method(10,20, add) { }
    */

class Calculations {
public Print(a:number,b:number):void {
console.log(a=${a}\n b=${b});
}
}
class Sum extends Calculations {
public Print(a:number,b:number):void {
super.Print(a,b)
console.log(Sum is ${a+b});
}
}
class Mul extends Calculations {
public Print(a:number,b:number):void {
super.Print(a,b)
console.log(Multiplication is ${a*b})
}
}
class Div extends Calculations {
public Print(a,b):void {
super.Print(a,b)
console.log(Div is ${a/b});
}
}
class Sub extends Calculations {
public Print(a,b):void {
super.Print(a,b)
console.log(Sub is ${a-b});
}
}
let cal:Calculations[]=[];
cal[0]=new Sum();
cal[1]=new Mul();
cal[2]=new Div();
cal[3]=new Sub();
console.log('----Individual Calculations----');
console.log('----SUM----');
cal[0].Print(30,40);
console.log('----MUL----');
cal[1].Print(20,60);
console.log('----DIV----');
cal[2].Print(52,26);
console.log('----SUB----');
cal[3].Print(156465,65465);

console.log('-----------------------------------');

for(var calculate of cal) {
calculate.Print(45,45);
}

map itterators (for-in for-of getting error) for reading values getting problem , able to read values using for loop

dear sir: map itterators (for-in for-of getting error) for reading values getting problem ,
I am able to read values using for loop only.

Error as follows:
D:\TSPROJ>tsc mapdemo.ts
mapdemo.ts:1:19 - error TS2583: Cannot find name 'Map'. Do you need to change your target library? Try changing the lib compiler option to es2015 or later.

1 let proddata= new Map();

My code : mapdemo.js is as follows please suggest on this:

let proddata= new Map();
proddata.set(1,"samsung tv");
proddata.set(2,"Mobile");
proddata.set(3,"Canon cemara");
proddata.set(4,"pendirive");
console.log(prod data size ${proddata.size});
let otherprod=new Map([
[5,"datacard"],[6,"Data Reader"],[7,"Memory Card 32 GB"],[8,"64 gb memory card"]
]);

console.log(Other prod data size: ${otherprod.size});

let mycart:Map<number,string>=new Map([...Array.from(proddata.entries()),...Array.from(otherprod.entries())]);

console.log(card items size ${mycart.size});
console.log('ACCESSING VALUES INDIVIDUALLY')
console.log(mycart.get(1));
console.log(mycart.get(2));
console.log(mycart.get(3));
console.log(mycart.get(4));
console.log(mycart.get(5));
console.log(mycart.get(6));
console.log(mycart.get(7));
console.log(mycart.get(8));

console.log("1)ACCESSING VALUES USING ITERATOR-- entries")

for(var entry of mycart.entries())
{
console.log(entry[0]+"--"+entry[1]);

}

console.log("2)ACCESSING VALUES USING ITERATOR values ")

for(let val of mycart.values())
{
console.log(val);
}
console.log("3)ACCESSING VALUES USING ITERATOR keys")

for (let key of mycart.keys())
{

console.log(key.toString());

//console.log(mycart.values[key]);
console.log(mycart.get(key));

}

console.log(mycart.size);
console.log("4)ACCESSING VALUES USING for loop IT IS ONLY WORKING ")

for(var i=1;i<=mycart.size,i++;)
{
console.log(value is: +${mycart.get(i-1)});
if(i>mycart.size)
{break; }

}

//console.log("val1 is:" +mycart.get(1)+"Property:"+mycart.get(2));

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.