Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
May 9, 2020 07:00 am GMT

Number 1 Problem for Developers - Solved!

One of the most difficult things in programming is coming up with variable names. If the situation is even a bit more complex, I always end up either coming up with bad non-describing name or just taking way too much time thinking of the name.

Variable naming is hard. But one thing that is maybe even harder is thinking of dummy data I can input and test my application with. Lorem ipsum can only do so much. When I need to create for example dummy users, it is just difficult to make up a user name or email, not to mention other info that a user might have, say for example an address.

I have a feeling that I am not alone with this. That is why I wrote this post. Because to be honest I no longer have this issue, thanks to Faker.js.

Faker.js

Faker.js is a fake data generator for JavaScript. We can use it to generate massive amounts of fake data in the browser and node.js. They have a long list of properties we can generate and I won't list all of them here (you can check it out here) but to mention few, you can e.g. generate user names, avatars, emails, location, address, etc.

Usage and the API is very easy and straight forward to use. If we want to use Faker.js in the browser and generate a user name and email, we can do it as follows.

<script src = "faker.js" type = "text/javascript"></script><script>  var randomName = faker.name.findName(); // Caitlyn Kerluke  var randomEmail = faker.internet.email(); // [email protected]</script>

So first we include faker.js file and then generate the name using faker. and the respective method name (you can find all the available methods from the documentation).

If we want to test Faker.js out, they have a demo site where we can poke around and get a better understanding of all the kind of data we can generate with it. The demo site is found here.

I hope you found this post helpful and learned something new. I have a YouTube channel where I consistently upload more videos and tutorials about web development. Go ahead and subscribe to the channel to get posted on all the new uploads!

Originally published at codepulse.blog on May 9, 2020.


Original Link: https://dev.to/tumee/number-1-problem-for-developers-solved-al5

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To