const record = [
{ year: "1980", result: "N/A"},
{ year: "1979", result: "N/A"},
{ year: "1978", result: "N/A"},
{ year: "1977", result: "N/A"},
{ year: "1976", result: "N/A"},
{ year: "1975", result: "N/A"},
{ year: "1974", result: "N/A"},
{ year: "1973", result: "N/A"},
{ year: "1972", result: "N/A"},
{ year: "1971", result: "N/A"},
{ year: "1970", result: "N/A"},
{ year: "1969", result: "W"},
{ year: "1968", result: "N/A"},
{ year: "1967", result: "N/A"},
{ year: "1966", result: "L"},
{ year: "1965", result: "N/A"},
{ year: "1964", result: "N/A"},
{ year: "1963", result: "N/A"},
{ year: "1962", result: "N/A"},
{ year: "1961", result: "N/A"},
{ year: "1960", result: "N/A"}
]
const winYear = (elem) => {
if (elem.result === "W"){
console.log(elem.year)
return elem.year
}
}
const superbowlWin = (arr) => {
return arr.find(winYear)
}
console.log(superbowlWin(record))
The goal is to return only the year, not the entire object. So, my intention is for 1969 to be returned. I logged elem.year
to the console and it logs 1969
however as soon as I try to return the value, I get the entire object.
What am I missing?