Telephone Number Validator ES6 Issue

Telephone Number Validator ES6 Issue
0

#1

Tell us what’s happening:

Hey everyone,

I’m having trouble here and I think it might be a logistical issue rather than a programmatic one. I’ve taken FCC’s JS course before in the legacy days and I came back to a wonderful surprise of lots more stuff to do. I decided to get into the JS projects and the first one up is the # validator. The only problem is, though I know my code works (through testing it in other mediums), it seems to only return ‘telephoneCheck is not defined.’

I’m a bit advanced in JS these days and noticed this was somewhat of an issue on other platforms such as Udacity as well, so my best guess is maybe this section doesn’t accept ES6 answers? Let me know if this is the case or what you guys think is the issue.

Thanks!

Your code so far


const telephoneCheck = str => {
	const newStr = str.split('').map(s => (!isNaN(s) && s !== " ") ? s : null).join('')
	
	return newStr.length === 11 ? newStr.split('')[0] === '1' ? true : false : newStr.length === 10 ? true : false
}

telephoneCheck("555-555-5555");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/telephone-number-validator


#2

Guess what! I was being lazy and forgot to add const or let (edited to show in the original post) to some variables. There are of course certain amendments that need to be made, but otherwise the code works fine now. Thanks to anyone who took a look!


#3

Good job tracking that down!