How does a string convert to a number?

  • 0
    Code to output in the order of written property code. I cannot understand how the line code = + code; converts strings to numbers. If the line is in the modal window appears - just the numbers 12, 5, 73. When I comment on it - the same thing, only with a plus. Why this or where can you read or watch about it?
    var codes = {
    	"+12": "USA",
    	"+5": "Poland", 
    	"+73": "Ukraine"
    }
    for (var code in codes){
    	var value = codes[code];
    	code =+ code;
    	alert(code + ":" + value);
    }
    JavaScript Penelope Brewer, Jan 29, 2019

  • 1 Answers
  • 0
    code = + code;


    1. Let's place the spaces correctly to make it clearer what + actually refers to: code = + code; .

    2. By running read .
    Vivien Wang

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!