I was ask a question in an interview to convert a string number to a number. eg : My string is "TEN" . and I have to convert it to number 10.
Please help.
Thanks
I was ask a question in an interview to convert a string number to a number. eg : My string is "TEN" . and I have to convert it to number 10.
Please help.
Thanks
if (string === "TEN") value = 10;
I think you misunderstood the interviewer's question. He meant getting the number that is currently in a string, not getting the number that is currently spelled out in a string.
But this has already been answered: https://stackoverflow.com/a/4090577/2725684