Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #38398
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: create 2 dimension tuple in Typescript and access items |
| Date | 2020-05-10 22:56 +0200 |
| Message-ID | <hhr838FelohU1@mid.individual.net> (permalink) |
| References | <e5d1fdb0-c8d9-4077-9cd0-445042c1d2d2@googlegroups.com> |
JRough:
> I have 3 rows of data , I want individual items inserted into web
> page , but on the first line where I define the tuple , I get an
> error and can't compile typescript?
>
> const productlist: Array( number | string| number|boolean| string|
> string)[]; *****
>
> productlist.push(431,"SamsungGalaxyNote7",59000,'Available',"url('MobileCart_Images_part1/SamsungGalaxy_Gold.jpg')","Samsung
> Galaxy Note 7 is a stylish mobile you can ever have. It has 64GB
> memory." );
>
> productlist.push(433,'SamsungGalaxyS6Edge',53499,'Available',"url('MobileCart_Images_part1/samsung_edge_silver.JPG')",
> "Samsung Galaxy Edge blah blah blah");
>
> productlist.push(434,'NokiaLumiai640XL',14990,'OutofStock',"url('MobileCart_Images_part1/lumia_640xl.jpg')",
> "Nokia Lumia 640XL blah blah blah" );
>
>
>
> And here is my script to insert the individual items into the html page:
>
> for ( var i = 0; productlist.length > i++){
This makes no sense and. What do you think this statement does? Probably
you mean this:
for (var i = 0; i < productlist.length; i++) {
> if ( i = 0){
If you want to compare things, don't use an assignment operator. The
correct way would be:
if (i == 0) {
> document.getElementById("pName0").innerHTML = productlist[i][1] ;
> document.getElementById("pPrice0").innerHTML = productlist[i][2];
> document.getElementById("pAvailable0").innerHTML= productlist[i][3];
> } else if( i = 1) {
See above - you don't want to assign the value 1 to the variable i but
*compare* i and 1:
} else if (i == 1) {
> document.getElementById("pName1").innerHTML = productlist[i][1] ;
> document.getElementById("pPrice1").innerHTML = productlist[i][2];
> document.getElementById("pAvailable1").innerHTML= productlist[i][3];
> }else {
Try to be consistent in your code style - always put spaces between
curly braces and the following word:
} else {
> document.getElementById("pName2").innerHTML = productlist[i][1] ;
> document.getElementById("pPrice2").innerHTML = productlist[i][2];
> document.getElementById("pAvailable2").innerHTML= productlist[i][3];
>
> }
> }
It looks like you don't have a lot of experience with ECMAScript. Maybe
you should do some more training.
--
Arno Welzel
https://arnowelzel.de
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
create 2 dimension tuple in Typescript and access items JRough <janis.rough@gmail.com> - 2020-05-09 16:49 -0700
Re: create 2 dimension tuple in Typescript and access items JJ <jj4public@vfemail.net> - 2020-05-10 19:56 +0700
Re: create 2 dimension tuple in Typescript and access items JRough <janis.rough@gmail.com> - 2020-05-10 06:09 -0700
Re: create 2 dimension tuple in Typescript and access items Arno Welzel <usenet@arnowelzel.de> - 2020-05-10 22:56 +0200
Re: create 2 dimension tuple in Typescript and access items JRough <janis.rough@gmail.com> - 2020-05-11 11:06 -0700
Re: create 2 dimension tuple in Typescript and access items JRough <janis.rough@gmail.com> - 2020-05-11 11:52 -0700
Re: create 2 dimension tuple in Typescript and access items "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-05-12 14:09 -0700
csiph-web