cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              This project compares the four score-ish richest people in the world (per Forbes 1000) with 50 of the poorest nations in the world. <br>
<div id="root" class="root">
</div><br>
My references are the following links:<br>
<a href="https://www.forbes.com/billionaires/list/#version:realtime">Rich People</a><br>
and<br>
<a href="https://en.wikipedia.org/wiki/List_of_countries_by_GDP_(PPP)_per_capita">Poor Nations</a><br>(These GDPs are the average based on information collected by the IMF, World Bank and CIA.)<br>
<ul>Fun facts:
  <li>The United States is proposing a wall along it's southern border, and proposing a cost of $25 billion to build it.</li>
  <li>The most expensive movie ever made (adjusted for inflation) is Pirates Of The Caribbean: On Stranger Tides, which estimated a $403 million budget to make.</li>
</ul>


            
          
!
            
              body {
    min-height: 100vh;
}
ul {  // UL
  font: 0.8em Arial;
  padding-top:0.2em;
  padding-left:0.14em;
  padding-bottom:-1.1em;
  margin-top:2.4em;
  margin-bottom:-1.5em;
}
li {  // LI
  font-face: Arial;
  list-style: none;
  padding:0.14em;
  &.richPersonLineItem {
    background-color: #aafbaa;
    margin-right:1em;
  }
  &.poNationLineItem {
    background-color: #c1a6a6;
    //color: white;
    margin-left:1em;
    padding-top:0.1cm;
    padding-bottom:0cm;
    
  }
}
.natName {
  background-color:#efb481;
}
.n_subtext {
  position:relative;
}
            
          
!
            
              let r = document.getElementById('root'),
//    p = document.getElementById("po"),
    richPeople = [
  {person: 'Jeff Bezos',                netWorth: 146900000000}, 
  {person: 'Warren Buffett',            netWorth: 83100000000}, 
  {person: 'Amancio Ortega',            netWorth: 71200000000},
  {person: 'Bill Gates',                netWorth: 94800000000},
  {person: 'Mark Zuckerberg',           netWorth: 65300000000},
  {person: 'Bernard Arnault',           netWorth: 82000000000},
  {person: 'Laurene Jobs',              netWorth: 21000000000},
  {person: 'Larry Page',                netWorth: 55700000000},
  {person: 'Larry Ellison',             netWorth: 58700000000},
  {person: 'Sergey Brin',               netWorth: 54300000000},
  {person: 'Carlos Helu Slim',          netWorth: 66800000000},
  {person: 'Paul Allen',                netWorth: 20200000000},
  {person: 'Ma Huateng',                netWorth: 39800000000},
  {person: 'The Brothers Koch (each)',  netWorth: 53700000000},
  {person: 'Jim Walton',                  netWorth: 42100000000},
  {person: 'S. Robson Walton',            netWorth: 41800000000},
  {person: 'Alice Walton',                  netWorth: 41800000000},
  {person: 'Mukesh Ambani',                 netWorth: 48800000000},
  {person: 'Jack Ma',                         netWorth: 39900000000},
  {person: 'Li Ka-Shing',                     netWorth: 32900000000},
  {person: 'Hui Ka Yan',                        netWorth: 29300000000},
  {person: 'Sheldon Adelson',                   netWorth: 39200000000},
  {person: 'Steve Ballmer',                       netWorth: 41600000000},
  {person: 'Beate Heister und Karl Albrecht Jr.', netWorth: 28800000000},
  {person: 'Francoise Bettencourt Meyers',        netWorth: 48600000000},
  {person: 'Lee Shau Kee',                        netWorth: 29500000000},
  {person: 'Leonardo Del Vecchio',                netWorth: 23700000000},
  {person: 'Georg Schaffler',                     netWorth: 20500000000},
  {person: 'Yang Huiyan',                         netWorth: 22000000000},
  {person: 'Jorge Paulo Lemann',                  netWorth: 26400000000},
  {person: 'Francois Pinault',                    netWorth: 31500000000},
  {person: 'Jacqueline Mars',                     netWorth: 25000000000},
  {person: 'John Mars',                           netWorth: 25000000000},
  {person: 'Michael Bloomberg',                   netWorth: 51000000000},
  {person: 'Phil Knight',                         netWorth: 33800000000},
  {person: 'Suzanne Klatten',                     netWorth: 23300000000},
  {person: 'David Thomson',                       netWorth: 25900000000},
  {person: 'Wang Jianlin',                        netWorth: 28000000000},
  {person: 'Joseph Safra',                        netWorth: 20100000000},
  {person: 'Vladimir Lisin',                      netWorth: 20101000000},
  {person: 'Thomas Peterffy',                     netWorth: 20100001000},
  {person: 'Michael Dell',                        netWorth: 24000000000},
  {person: 'Masayoshi Son',                       netWorth: 23500000000},
  {person: 'Dietrich Mateschitz',                 netWorth: 25900000000},
  {person: 'Stefan Quandt',                       netWorth: 20200000000},
  {person: 'Elon Musk',                           netWorth: 19300000000},
  {person: 'Tadashi Yanai',                       netWorth: 21900000000},
  {person: 'Giovanni Ferrero',                    netWorth: 21200000000},
  {person: 'Len Blavatnik',                       netWorth: 20500000000}
];    
function brokeNation (nation, GDP, population) {
  this.nation = nation;
  this.population = population;
  this.GDP = (GDP.reduce((a, b) => a + b, 0)) / GDP.length;
  this.sumWealth = this.GDP * this.population;      //console.log(this.nation+" may be worth "+this.sumWealth);
};
let brokeNations = [
  new brokeNation ('Somalia', [400], 14317996),
  new brokeNation ('South Sudan', [1503, 1500], 12230730),
  new brokeNation ('Central African Republic', [652, 699, 700], 4594621),
  new brokeNation ('Niger', [1153, 1017, 1200], 20672987),
  new brokeNation ('Mozambique', [1266, 1247, 1300], 28829476),
  new brokeNation ('The Gambia', [1667, 1689, 1700], 2051363),
  new brokeNation ('Madagascar', [1554, 1555, 1600], 24894551),
  new brokeNation ('Burundi', [814, 778, 800], 10524117),
  new brokeNation ('Eritrea', [1410, 1200], 4954645),
  new brokeNation ('Guinea', [1265, 1311, 1300], 12395924),
  new brokeNation ('Papua New Guinea', [3541, 0, 2800], 8084999),
  new brokeNation ('Haiti', [1810, 1815, 1800], 10847334),
  new brokeNation ('North Korea', [1700], 25368620),
  new brokeNation ('Mali', [2169, 2211, 2200], 14517176),
  new brokeNation ('Rwanda', [2081, 2036, 2100], 11262564),
  new brokeNation ('Uganda', [2352, 1864, 2400], 41487965),
  new brokeNation ('Zimbabwe', [2277, 2086, 2300], 16150362),
  new brokeNation ('Burkina Faso', [1884, 1870, 1900], 20107509),
  new brokeNation ('Guinea-Bissau', [1730, 1582, 1500], 1815698),
  new brokeNation ('Malawi', [1172, 1202, 1200], 18091575),
 // new brokeNation ('Kenya', [3496, 3286, 3500], 49125325), //== $168 billion
  new brokeNation ('The Sierra Leone', [1672, 1473, 1600], 7075641),
  new brokeNation ('Sao Tome And Principe', [3072, 3229, 3400], 199910),
  new brokeNation ('Djibouti', [3567, 3600], 942333),
  new brokeNation ('Togo', [1550, 1491, 1500], 7965055),
  new brokeNation ('Timor Leste', [4187, 5800], 1167242),
  new brokeNation ('The Congo', [785, 887, 800], 78736153),
  new brokeNation ('Liberia', [855, 813, 900], 4503000),
  new brokeNation ('Benin', [2219, 2266, 2200], 10872298),
  new brokeNation ('Afghanistan', [1889, 1981, 1900], 34656032),
  new brokeNation ('Yemen', [2300, 2300], 27584213),
  new brokeNation ('Palestine, West Bank And Gaza', [1323, 4300], 4550368), 
  new brokeNation ('Ghana', [4605, 4641, 4600], 28308093),
  new brokeNation ('Chad', [2433, 1941, 2400], 13670084),
  new brokeNation ('Cambodia', [4010, 4001, 4000], 16245729),
  new brokeNation ('Kyrgyzstan', [3652, 3726, 3700], 6019480),
  new brokeNation ('Tajikistan', [3131, 3180, 3100], 8734951),
  new brokeNation ('Marshall Islands', [3301, 4072, 3400], 53066),
  new brokeNation ('Micronesia', [3392, 3622, 3400], 104937),
  new brokeNation ('Cameroon', [3359, 3694, 3400], 23439189),
  new brokeNation ('Kiribati', [1823, 2047, 2200], 110136),
//  new brokeNation ('Tanzania', [3283, 2946, 3300], 55572201), //== $176 billion
  new brokeNation ('Laos', [7367, 7023, 7400], 6758353),
  new brokeNation ('Senegal', [2678, 2712, 2700], 14320055),
  new brokeNation ('Honduras', [5499, 4986, 5500], 9112867),
  new brokeNation ('Nicaragua', [5823, 5842, 5800], 6167237),
  new brokeNation ('Moldova', [5328, 5334, 5000], 2998235),
  new brokeNation ('Vanuatu', [2631, 3081, 2600], 272459),
  new brokeNation ('Mauritania', [4328, 3854, 4500], 4301018),
  new brokeNation ('Lesotho', [3601, 3029, 3000], 2203821),
  new brokeNation ('Nepal', [2690, 2682, 2700], 28982771),
  new brokeNation ('Ivory Coast', [3857, 3953, 3900], 23740424)
],
    ppl = richPeople.sort(function(a, b) {                  //sort richest on top!!!
                                      return b.netWorth - a.netWorth;
                                    }),
    nats = brokeNations.sort(function(a, b) {               //sort richest on top!!!
                                      return b.sumWealth - a.sumWealth;
                                    }),
    finalList = new Array();

//console.log("ppl are  "+ppl);

/*  START BUILDING LISTS and combining dup numbers  */
for (var p=0;p<ppl.length;p++) {
  if (p<ppl.length - 1) {
    if(ppl[p].netWorth == ppl[p+1].netWorth) {
      ppl[p].person += ' and '+ ppl[p+1].person+' (each)';
      ppl.splice(p+1, 1);
    }
  } 
  finalList.push(ppl[p]);
}
for (var n=0;n<nats.length;n++) {
  finalList.push(nats[n]); 
}//the marginTop of p has to fall where the richest poor nation matches the lowest billionaire
finalList.sort(function(a, b) {               //sort richest on top!!!
                if (a.hasOwnProperty('netWorth') && b.hasOwnProperty('sumWealth')) {
                    return b.sumWealth - a.netWorth;
                } else if (a.hasOwnProperty('sumWealth') && b.hasOwnProperty('netWorth')) {
                    return b.netWorth - a.sumWealth;
                } else if (a.hasOwnProperty('netWorth') && b.hasOwnProperty('netWorth')) {
                    return b.netWorth - a.netWorth;
                } else {
                  return b.sumWealth - a.sumWealth;
                }
               });
class MasterList extends React.Component {
 render() {
    const pn = finalList.map((fl, i) => {
       if (fl.hasOwnProperty('person')) {
         let rpLineHeight = parseInt(fl.netWorth / 500000000),
             rpFontsize = fl.netWorth / 2050000000,
             rpLineOpac = 100;
          return <li id={fl.person+"_lineItem"} className = "richPersonLineItem" key={i}
               style={{ height: rpLineHeight, 
                        fontSize: rpFontsize,
                        opacity: rpLineOpac}}
               key={fl.netWorth}>
                        {fl.person}: ${fl.netWorth.toLocaleString({ style: 'currency'})}
             </li>;
       } else {
         let pnLineHeight = parseInt(fl.sumWealth / 320250250),
             pnFontSize = fl.sumWealth / 1900000000,
             subtextFontSize = fl.sumWealth / 3400000000,
             subtextPTop = -Math.abs(fl.sumWealth / 4500000000);
         if(pnFontSize > 11) {
            return <li id={fl.nation+"_lineItem"}className = "poNationLineItem"
                  style={{height: pnLineHeight, 
                        fontSize: pnFontSize }}
                  key={fl.sumWealth}>
                        <span className="natName">{fl.nation}: </span> 
                          ${fl.sumWealth.toLocaleString({ style: 'currency'})}
                        <p className="n_subtext"
                           style={{fontSize: (subtextFontSize > 6) ? subtextFontSize : 6,
                                 top: subtextPTop}}>
                            based on a population of {fl.population} as of 2017, times 
                            an estimated national GDP (PPP) of ${fl.GDP.toLocaleString({ style: 'currency'})} USD</p>
                          
              </li>;  
         } else {
           return <li id={fl.nation+"_lineItem"}className = "poNationLineItem"
                  style={{height: 18, 
                        fontSize: 11 }}
                  key={fl.sumWealth}>
                        <span className="natName"><b>{fl.nation}</b>: </span> 
                          ${fl.sumWealth.toLocaleString({ style: 'currency'})}
              </li>;  
         }
       }
    });
    return (
      <ul>
         <h1>49 Rich People, 50 Poor Nations</h1>
        {pn}
      </ul>
    );
  }
}

ReactDOM.render(
  <MasterList />,
  r
);

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console