Ray Bowman

Ray Bowman

  • NA
  • 43
  • 740

How do I embed numbers into strings in strict mode?

Sep 7 2021 9:02 PM


Hi all,

I am trying to assign a file path to a variable in Typescript, which is being executed in Node.JS.

This is the path:

const path = 'C:\\Software Development\\2020_12_21_NET_NodeJS\\NET_NodeJS_01';

error - [Octal escape sequences are not allowed in strict mode.]

My thought at that point was to break the string into elements of an array, then join the elements into the finished string.

const path_parts = [
        'C:\\Software Development\\',
     '2020_12_21_NET_NodeJS\\NET_NodeJS_01'
                   ];

const path = path_parts.join ();

error - [Numeric separators are not allowed at the end of numeric literals]


Try again:

const path_parts = [
        'C:\\Software Development',
     '\\2020',
     '_12', '_21_NET_NodeJS\\NET_NodeJS_01'
                   ];

error - [Octal escape sequences are not allowed in strict mode.]

Try again:

const path_parts = [
        'C:\\Software Development\\',
     '2020',
     '_12', '_21_NET_NodeJS\\NET_NodeJS_01'
                   ];

error - [Unexpected number]

Try again:

const path_parts = [
        'C:\\Software Development\\',
     '2020',
     '_', '12', '_21_NET_NodeJS\\NET_NodeJS_01'
                   ];

error - [Unexpected number]


Try removing the first element in the array, then try again:

const path_parts = [
     '2020',
     '_12', '_21_NET_NodeJS\\NET_NodeJS_01'
                   ];

no error

Any help would be appreciated!
 

 


Answers (1)