Convert a number in a string variable into a number in Javascript, jQuery

It is possible to get frustrated when you are coding in JavaScript and are trying to do some arithmetic calculations in the course of your JavaScript programming.

Here, it is possible to find out that 1000 + 1 is equal to 10001 and 10001 + 10 equals 1000110.

This is where you find out that all that you learnt in the school is wrong. It is also when you feel just a wee bit superior to the computer, because you know that sometimes, it has to be specifically instructed on what to do, how to interpret and calculate.

In JavaScript, there is one function that we can use to tell the computer that we are dealing with numbers and not strings. We use the function Number("numberInStringForm") to convert a number inside a string into a number.

This happens most of the time when numbers are part of a web form/report where all content is text. Based on the position of the text, based on the id or class name that we identify them with, we have to extract the content, which will be by default in "string form".

This is where we use the Number() function to convert them into number form again. After this Number() function is used, the number in the string variable is converted into a number, upon which we can then use the arithmetical operators (+-*/^ etc) to get the numerical answers.

Usage: stringToNumber =Number("12345")

Enforcing Helmet Rule in Chennai!!! Misplaced Priorities?!

News: Helmets are mandatory in Chennai, for even the pillion rider, rules the  High Court, apparently to save the precious lives of its citizens.

Is it a case of Misplaced Priorities?! Let us have a look.

Take a look at some statistics here.

3000 children die EVERY DAY in India from poor diet related illness, that is over one million lives every year.
  • 24% under 5 deaths
  • 30% neo natal deaths
  • 1 in 4 children are malnourished, which means that 25% of the population will not be able to fend for themselves, depending on others for life
  • the first 1000 days are critical, from birth to the age of 2
On the other hand, only 207551 people died of road related incidents in India in 2015

Causes mentioned are
  • overspeeding
  • driving under influence
  • not using seat belts and helmets
  • failure to maintain lane
  • not yielding to oncoming traffic
Strangely, there is no mention of bad roads in these data.

People allegedly claim that they can identify many unmarked speed breakers and bad roads in their respective areas.

In India, we should know and be convinced that laws make no sense. People will do or not do a certain thing, only when they are convinced about it.

And in a population of 1+ billion, let us accept it; there is a sense of peace and tranquility because of the inherent peace loving nature of the citizens; not because of the police or the military.

It is easy to enforce a rule, because of the fact that one is in power. We were wondering if the judge did seek information from the government on the steps taken to educate the children at school on road safety practices. After all, they are the future of the country.

A helmet may save the head, but what about the other parts?

Just step out on the roads and it is very easy to find out school children driving on the wrong side of the road, parents on motorcycles with children driving on the wrong side of the road, speed breakers with no markings, vehicles of all kinds paying scant respect for the traffic signals, foot deep potholes on main roads and highways and so on.



Seeking a Permanent Solution to traffic woes

Instead of increasing penalties, which will only lead to misuse of authority, attention should be given to mould the children early, in order to make them responsible future citizens.
 
That is the way to go for arriving at a permanent solution!


The problem is in the mindset. And, the focus should be long term; short term solutions do not work long-term, as we have learnt from past experiences. Till the long-term solutions bear fruit, short term solutions may be implemented.

To begin with, by regulating the process of providing licenses with a fully automated driving license test, which will test the applicant on the road rules, in addition to the mandatory driving test, the government can ensure that whoever gets the driving license are fully qualified deserving drivers.

References:
https://www.youthkiawaaz.com/2015/10/ten-facts-about-hunger/
https://www.indiafoodbanking.org/hunger
https://www.actionagainsthunger.org/hunger-facts
https://en.wikipedia.org/wiki/Traffic_collisions_in_India
https://sites.ndtv.com/roadsafety/important-feature-to-you-in-your-car-5/
https://www.ndtv.com/india-news/every-day-400-people-die-in-road-accidents-in-india-shows-government-data-1403899

Two Reasons Google Ads Lead Form is Rejected

Two Reasons Google Ads Lead Form is Rejected An Investigation on Why the Google Ads Lead Form in My Google Ad Got Rejected. I just...

Most Popular

Copyrighted.com Registered & Protected DWYE-NHTO-NBNH-7FFM