import express from 'express';
import cors from 'cors';

const app = express();
app.use(cors());

app.get('/task2a', async (req, res) => {
  try {
    const a = parseFloat(req.query.a);
    const b = parseFloat(req.query.b);
    const sum =
      (req.query.a && !isNaN(a) ? a : 0) +
      (req.query.b && !isNaN(b) ? b : 0);
    res.send(`${sum}`);
  } catch(err) {
    console.log(err);
    return res.json({
      err
    });
  }
});


app.listen(3000, function () {
  console.log('Example app listening on port 3000!');
})

@@ -432,16 +432,778 @@
 %7D%0A%7D);%0A%0A%0A
+app.get('/task2b', async (req, res) =%3E %7B%0A  try %7B%0A    const fullname = req.query.fullname %7C%7C '';%0A    const re = new RegExp('%5E(.%5B%5E 0-9%5D*)?( )?(.%5B%5E 0-9%5D*)?( )?(.%5B%5E 0-9%5D*)?$', 'im');%0A    const parsed = fullname.match(re);%0A    console.log(fullname);%0A    console.log(parsed);%0A    if (!parsed) %7B%0A      return res.send('Invalid fullname');%0A    %7D%0A    if (parsed%5B1%5D && parsed%5B3%5D && parsed%5B5%5D) %7B%0A      return res.send(%60$%7Bparsed%5B5%5D%7D $%7Bparsed%5B1%5D.charAt(0)%7D. $%7Bparsed%5B3%5D.charAt(0)%7D.%60);%0A    %7D%0A    if (parsed%5B1%5D && parsed%5B3%5D) %7B%0A      return res.send(%60$%7Bparsed%5B3%5D%7D $%7Bparsed%5B1%5D.charAt(0)%7D.%60);%0A    %7D%0A    if (parsed%5B1%5D) %7B%0A      return res.send(parsed%5B1%5D);%0A    %7D%0A    res.send('Invalid fullname');%0A%7D catch(err) %7B%0A    console.log(err);%0A    return res.json(%7B%0A      err%0A    %7D);%0A  %7D%0A%7D);%0A%0A
 app.list
@@ -1281,9 +1281,10 @@
 0!');%0A%7D)
+;
 %0A

task2b